C++ program problem

Suki

you will get nothing
Joined
Oct 23, 2002
Messages
509
Location
canada
I'm working on a neural network simulator, writing it in c++ using microsoft visual studio 6.

I've come to a road block.

i've defined a neuron class and a group class.
a neuron object holds all the information spesific to the individual neuron. like it's current output.
a group object holds a vector of neurons and information about the connections made by the neurons it contains and information about how they should process their output.
the connections between nodes are done directly with pointers.
in some situations i'm going to have to access information held by the group through a pointer to a neuron in the group.
how can I do that without giving each neuron a pointer to the group that it's contained in? i can't figre it out.
the best I can figure so far is to decompose the neuron class and have insted of a vector of neurons have a vector of neuron outputs, a vector of wieght vectors. but then the problem is that I the connectors need a pointer to a group and an index for the vector of outputs...
am I making sense?
any ideas?

thankyou
 
Yes, you're making sense, but I don't see a good solution for your problem. Why can't you give all neurons a pointer to the group they belong to?
 
Originally posted by yaroslav
Yes, you're making sense, but I don't see a good solution for your problem. Why can't you give all neurons a pointer to the group they belong to?
I could do that I'm just hoping there's an nicer way to do it. I don't like having to tell all 50 nodes in a group that they belong to that group.
it just seems like it could go wrong so easily... of course I have little experience with this stuf.
 
Suki, is it possible to post some code?
I can't clearly see where your problem is located, but I know my way around C++.

Greetings Jurimax
 
instead of passing around pointers to neurons you could pass around this:

struct pointercluster
{
neuron *npointer;
group *gpointer;
};
 
Unless you are working on that NN simulator as a project, i.e. if you just write it to have a NN simulator for something you need to do, I suggest you stop immediatly. ;)

MATLAB has by far the best NN implementations for the standard needs. Even the default install has a NN package installed and you can download many more NN toolboxes from almost any site dealing with NN, pattern recognition, etc.
And in most cases they are implemented in MATLAB. :yeah:

I´ve written a small NN simulator in C++ myself, to compare it with the Support Vector Machines. It worked fine but was a hell lot of work even to build the most simplest of all implementations.

Once I changed to MATLAB, I could finally work on the real problem and not create something that is already there and of course better.

So again, unless you do it as a software project, use MATLAB. And of course, the MATLAB sourcecode is nothing much more than C++ anyway, so you can program your own NN toolbox there, too.
:D
 
yaroslav, nihilistic

either of those soloutions will work. I guess the question is jsut which would work better.

nihilistic

I'm still not to good with structures. How are they any different than classes?

Jurimax

the code is very fragmented and i don't think posting any would help--> I have pages and pages of notes but not nearly as many comments.I have my answer, I was just hoping I didn't have to back up so much. I just know now to plan things out a little better next time.

Lucky

well I do have to learn C++ for school. I figure this will be a good way to force myself deeper into it.
This is the first I hear about MATLAB. I've been looking around the website, it looks prety nice... in fact even better than that because my next question was going to be about where I can find basic graphic functions so I could visualise these things without resorting to drawing pictures in ascii, of course I still would like to know that... anyone know?
I'll put a little more thought into this. I can definatly see how this can be a great help, but I still kindof want to build this, I'm sure I'll change my mind once i see the program

thank you all.
 
Originally posted by Suki
nihilistic

I'm still not to good with structures. How are they any different than classes?

structs are pretty much the same as classes except that by default all members are public. If you don't feel comfortable, you could use classes as containers if you want.
 
Originally posted by nihilistic


structs are pretty much the same as classes except that by default all members are public. If you don't feel comfortable, you could use classes as containers if you want.

is that all?
well like I said the point of this is to learn things...

oh and there was one other question I had. the books and tutorial things I have have plenty of information on how to overload operators but I can't find/figure out how to overload the subscript operator [] for my custom classes so it can be used with the assignment operator boath ways. I can only get it to work for retrival.

thing1=things[5] \\work works
things[5]=thing1 \\ doesn't work

I've tried doing the overloading code a few different ways, with and without pointers but I can't get it to work. any ideas for that?
 
MATLAB is THE program for any engineer, cybernetic programmer or programmer in general, and of course for mathematicians, too. And as you might have noticed, you can easily learn C/C++ with it as well and you have many function already implemented, as a graphical interface. :yeah:

Concerning struct and class, they are not the same.
Struct actually is based on C, there is nothing object-oriented about it, while class is of course solely object oriented.
So you have to decide between programming in C or in C++. You can of course mix both, since usually all commands work in both. But some commands, declarators, etc. are only available in standard form and have a complementary object in OO.
So choose wisely. ;)
:D
 
Originally posted by Suki


is that all?
well like I said the point of this is to learn things...

oh and there was one other question I had. the books and tutorial things I have have plenty of information on how to overload operators but I can't find/figure out how to overload the subscript operator [] for my custom classes so it can be used with the assignment operator boath ways. I can only get it to work for retrival.

thing1=things[5] \\work works
things[5]=thing1 \\ doesn't work

I've tried doing the overloading code a few different ways, with and without pointers but I can't get it to work. any ideas for that?

That is of course not all, but I think Lucky explained it better. Also, I would like to advise you not to over load operator[]. It's way too easy to confuse that notation with the array notations. Instead, maybe you can use one of the bit shift operators that usually don't get used, probably this one: ">>".

Originally posted by Lucky
MATLAB is THE program for any engineer, cybernetic programmer or programmer in general, and of course for mathematicians, too.

That's rather bold. To the best of my knowledge, MATLAB's tremendous number-crunching capabilities makes it suitable for linear algebraic calculations and numerical analysis. I do not know what implications those stuff may hold for engineers, but I have the impression that programmers and mathematicians usually use either a more structured platform like mathematica.

Originally posted by Lucky
Concerning struct and class, they are not the same.
Struct actually is based on C, there is nothing object-oriented about it, while class is of course solely object oriented.
So you have to decide between programming in C or in C++. You can of course mix both, since usually all commands work in both. But some commands, declarators, etc. are only available in standard form and have a complementary object in OO.
So choose wisely.

True, but he isn't going to extend that struct/class anyway.
 
Back
Top Bottom