jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check line 13 (and line 17 for good measure). One has something it doesn't need and the other needs something.

mitrmkar commented: line 13 == good catch +5
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

By the way it should be #include <iostream> not iostream.h which is an outdated prestandard file. main() should be of int type (the way you have it, it's probably implied but that's not a good habit to get into).

Also, what if you wanted to use x and y further along on your program. There might be a problem there...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Get rid of the z= on line 9, and pass in the address of z as the third parameter (just like you did with x and y).

Now, in your function you must actually do the calculation with *c (as changing a and b will do nothing to c).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

By topology I meant like backpropagation (which is probably what you are using) or Learning Vector Quantization there are many others in the Matlab toolbox too. Luckily once the dreaded part of getting the data in is over you can move it between different ones. You'll have to decide the relationship between the layers (by 2 layers do you mean inputs right to an output layer or a hidden layer in between?). Try to figure out how to change the setting for the size of the input layer. I no longer have access to Matlab (and I haven't used the NN toolbox in quite a few years) so I'm afraid I can't give you anything more than the overall theory and what I remember.

(If you haven't already) You should definitely read the pdf that goes with the Neural Network toolbox, there's a ton of information there and a good bibliography. It's available over the internet too I believe.

Unfortunately training and using these things can be more of an artform than a science.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There are potentially a few issues here.

If the document is up and running in word it may be locked as far as the file system is concerned (I have not tested this).

If you are trying to read from a Word document in text mode (as in from a .doc file from a recent Word release) instead it needs to be a binary read/write (unless you are doing word 2007, in which case it's in XML).

If you are simply trying process between (plain) text files leave them closed and let your program do the opening, closing, and creating of the new file.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hello there all. Thank you for responses. Jonsca, thank you for your response :) however i did not understand a single sentence other than in the beginning paragraph.

I apologize. I wasn't trying to talk over your head I just figured I would give you some specific examples and you could Google them to death. For references about the differential equations aspect see http://en.wikipedia.org/wiki/Numerical_ordinary_differential_equations"]this and this but just imagine that there are tens or hundreds of equations that all depend on each other (akin to a system you might have seen in algebra like x -y = 3, x+y = 5). The matrices become huge very quickly.

But I don't understand how equations can make up/produce so much data that it takes Terabytes to store the info.

Imagine you're those physicists at CERN. You want to record the position and trajectory of millions of particles and on top of that you want to take the data at time intervals of 1 ns. Right there you would have a million billion datapoints per second (my numbers are completely exaggerated since I know next to nothing about what they trace but you get the idea).

@GrimJack - thanks for clarifying some of the points on the protein structure prediction.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

On line 18 you try to cout the h value before it was read in. I'm not sure what you were trying to do there. You declared it on 16 but you didn't initialize it. Initializing it would be char h = 'z'; . It never hurts to do that so that it has a value (you can pick something more logical than 'z') but doing it without fixing the other error will just mask the problem.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't see a declaration for your << operator in the header and you don't show your implementation file so I don't know if it's there either. In you declaration it should be declared as a friend.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

inFile.open(filename.c_str()); will open up the file using the filename (that c_str() method provides the C string representation)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check the number of inputs units you have set up. It's probably defaulted to 2. Which topology are you using?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What type of network are you using? For something like the backprop you have a training set of vectors and an "ideal" set of results for them to train the system. So based on what you are saying for a vector

[600.4;
 229.2;
      3]

you'd expect and output of:
[0.274;
    12]

Then you run it and the system will adjust itself based on the error. Normally people split their data up into training and testing sets. The training you have the outputs of (your targets) and the testing you are seeking the output. Hopefully you have many more training data as sometimes it takes quite a bit to get a nice low error. There's a balance to be struck though because you don't want your net to overgeneralize either.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
ostream & operator << (ostream &out, BigNumber n)
{
   double temp = n.getCoefficient();
   if (temp == 0) 
  {        
      out << 0;        
   }    
  else 
  {        
     out << temp << " x 10^" << n.getExponent();   
  }     
  return out;   
}

That wasn't really at issue. OP was trying to "reduce" the number to scientific notation so if I wrote 100 x 10^2 it would display as 1x10^4.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Scratch the idea about the print statement you'd have to change it to return a string for it to work. Move it right under line 3 in that code that you have posted.

It's some processing that I think would best be done elsewhere. The << operator customarily does not modify the object it's outputting.

Putting that code from 59-63 in the constructor seemed like a logical choice though it could have been a completely separate private method. If it's in the constructor, it's over and done with and in simplified form.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Say that your first else if has an if statement within it and then that if statement has yet another. This is nesting.
(not sure what language you're using so I'll keep it generic)

if ()

else if()
    if()
       if()
       else

else if()
etc.

You should be able to figure out the answer at this point.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

value1 = stk.pop( ); doesn't work because pop is void.
Use your top method[/URL] to access the value of the next item on the stack and then pop it off after that with the pop() method.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Maybe move lines 59-63 to the constructor (still changing the int count statement). Then you can change the signature of ostream & operator<<(ostream & out,const BigNumber & n) . Then you'll just have 65-71 left in the operator method.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a quick look at an ASCII table (http://web.cs.mun.ca/~michael/c/ascii-table.html for example) as to how 'a' relates to 'A'

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Let me preface this by saying that I am not an expert in any of these fields but I have had some exposure to the underlying theory, so facts are AFAIK. Please pardon any textbookiness.

The least common denominator is they all involve the solution of simultaneous differential equations (depending on which model is used). Such work requires large scale matrix transformations, the size of the matrix being proportional to the degree of the equations. The more you can exploit granularity (that is how small of a piece can you parcel out to each individual processor and still be effective) the faster your calculations get done.

There are other specific factors for each case, for example the protein structure prediction involves a lot of combinatorics calculations to posit the pool of possible structures along the way. Weather predictions over long ranges of time require ever so small timesteps to maintain their accuracy. I haven't read anything about the army's project so I'll keep my assumptions on that to myself, but suffice it to say the more neurons you have in the simulation the greater the likelihood of approximating phenomena at the subcircuit level.

Phew, so I don't even want to go back and reread that. :) Hope this gives you some search terms that you can google.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

As far as Rational( int = 0, int = 1 ); , test that way of writing it to make sure it works. A more effective way to write it would be Rational(int num=0,int den=1):Numerator_(num),Denominator(den) {}

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You should declare count (and initialize it!) before the while loop then increment it within. What you are doing there doesn't make any sense syntactically. I also question doing this much processing in the overloaded << method. Normally the second parameter is of const Bignumber & type, so perhaps delegate some of the processing to your print method and call that within operator<< .

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hi, I am working on visual studio 2008 C++ and I have done the C++ general code, my question is can I convert my general code to be C++ CLR in visual studio 2008? This will make my work easier.

This is an excerpt from a book by Nishant Sivakumar that has a nice chart about handles versus pointers in section 1.4. To answer your question almost any code is "convertible" but the extent to which you have to marshal between managed and unmanaged types will vary.

And I have one more small question is I have made a textbox in C++ CLR, how can I load text from a text file? It is easy to load text file under C++ general but in CLR I don't know yet?

Thank you!

Use streamreader. Create the object with the name of your textfile and use Read, ReadToEnd or ReadLine methods.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to static_cast<int>(something) you can't just have it by itself. In reality you may not even need it at all, remember that chars are one-byte ints. If anything at all you'd almost need static_cast<char> for that quantity to put it back into buffer.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The first problem is your indicies are off on sum+=val[x-i]*pow(2.0,i-1); Write it out on paper, in an example with an 8 digit number, you want:
val[0] times 2^7+ val[1]*2^6 etc which means you also need to change where the for loop begins. Put some couts in there to see how values progress as the loop proceeds.

Also, since val is a string, what value would an element have if it were '1' or '0'. A hint, it's not 1 or 0. Your string holds characters which have an ASCII value associated with them. A simple solution is to subtract '0' from the character value.

It's not consequential but sum should probably be a double as that is what is coming back from pow().

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Right after your cin >> n line, put a cin.ignore() . When you are entering the number there's the newline that came after it when you pressed enter. It gets stuck in the stream. The getline (the first time through the loop) is simply taking this '\n' in and thinking that it reached the end of a line already. The next three inputs go in okay. The ignore will pick up the excess character and the stream will be empty in time for your getline.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Ala00003 the right idea. A dot product is really a projection of one vector on to another but can be thought of as a sort of correlation. Look into the other formula for the dot product (they are in fact equivalent but with n years of brain rust I can't run through it) which for vectors of points [x0,x1,x2,x3] and [y0,y1,y2,y3] is x0y0+x1y1+x2y2 + ... (you're essentially multiplying XY' where Y' is Y transpose).

As far as the energy goes, I don't want to have all the fun. Take a look at this http://en.wikipedia.org/wiki/Energy_%28signal_processing%29 or a related article. Just remember these equations are for continuous time system and you need to convert them to discrete.

Anyway, try it out in the code. Post back if you have any problems.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It is not exception safe for instance. Why are you trying to define a string class anyway when the standard provides one?

Without making too many assumptions this is probably a homework assignment for an intro class (where reinvention usually reigns supreme). We could probably debate the exceptions issue ad nauseum but I don't think the OP would benefit from that at this stage.

I certainly agree with the rest of your points.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If I remember correctly, what you are referring to as outputs are actually the targets. The outputs are what your training set actually yields when run through the network.

An example (largely artificial) say you have a network that will add, so your inputs would look like:

[1 1 1 1;
 3 5 6 9]

Your target would look like this:

[4 6 7 10]   (1+3 = 4, 1+5 = 6)

Say the net is error prone when the second factor is even, so the output could be:

[4 5 9 10]

So in calculating the mean squared error (in reality this would depend on if you were training it by epoch or not) you would use the values

[4 6 7 10] and [4 5 9 10]
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

He's parked it in the includes directory on the search path for his compiler. I thought that too at first.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A few preliminaries: <iostream.h> has long been standardized to <iostream> . When using string.h with C++ you should include it as <cstring> . Also the conio routine is non-standard. Finally, main must return an int according to the standard.

You need to change your = operator to look something like this:

public: String & operator=(const String & str)
    {
	(*this).assignstring(str.string); //or this->assignstring(str.string);
	return *this;
    }

You were trying to equate a String (your class) object to a char * which wouldn't work. I would take out line 36. If you're redefining string (your member variable) again on line 37 I don't believe you need to delete the old one first, someone can probably clarify that for you. I think having your destructor do that when all is said and done is enough.

Just a suggestion. I know this is a standalone project and you may never see it again but it's a good habit to get away from naming things after existing entities (e.g. string vs. std::string in particular but String could turn into string with a typo) unless you explicitly plan on putting this into a namespace and qualifying the names.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 95: The arguments to this function are pointers use push(&rowElement, &colElement); Line 161: Opposite problem, row and col are pointers (the ones passed into the function, so dereference the right hand side like newPtr->row = *row; Line 199: same as 161.

Line 184: same as line 95
(around 184 you shouldn't have to prototype pop in this function (you can I suppose) but you should put it up before main() with the rest of them.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There are no conditions on an else statement. You could have an else if with conditions but I don't think that's what you need here.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You probably need a cin.ignore() after line 13 to sop up the extra '\n' but I can't see firstChoice() to verify that.
When you take in a character and press enter the newline hangs around in the buffer and gets taken in by the next function looking for input (your getline() in choice 4). getline() reads the '\n' which is its delimiter and finishes all without getting a filename.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just read it into a "dummy" variable of the same type.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

while (n >= 1 && n <= 30) since the while loop runs while it's true you want it to cut out when either one of these is false. It's a bit counterintuitive at first.

To solve your other problem, I believe you need

float n = 0f;
float total = 0f;
float dollaramount = 0f;

to specify that those are float constants.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you write a program that prints out every value from 1 to 20? What type of loop are you thinking of using? With those questions in mind, try something out first and post your code and we can help you with it.

EDIT: Well apegram edged me out by a 1/4 second.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

cols = 2, right? I had made a goof on my cout (I had the old value for the formula) but I had it right when I was actually doing the manipulations. See my test program.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's not what I got, I just tried it you run off the end of the array. I had along the lines of copy[i] = copy[i]+ (A[(i % cols)+(j-1)*cols])*(B[(i/cols)+(j-1)+(i+1)%cols]); Since the i value is the same you don't need to change that first array indexes at all but you have to follow that 2/3/2/3 pattern for the second array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You did fine with this posting. Sometimes it's nice to put something like your text there (sample output) into code tags to keep it neat. I've got to admit I really haven't much of an idea about the requirements or the goals of the program. Could you post the stores.data (if it's not too long)? I think you were trying to show me what the output is currently from those two functions but it would also be good to see what it is supposed to look like.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Would it be possible for you to use an array called W and fill in the elements 12, 13, 14, etc. I understand what you are trying to do but I do not believe C has an "eval" type command that can assign variable names at runtime. How would you know which variable to access at any given time? You may have to rethink your methodology a bit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
struct addressbook personaladdressbook[50]
{
  char name [NAME];
  char address [ADDRESS];
  char phone [PHONE];
  char email [EMAIL];
  char Target[NAME];
} addresses[NUMAD];

With this we've confused you a bit, remove both additions from this block. To instantiate a struct do either:

struct mystructname{
//members here - left out for clarity
} mystructarray[50];
and nothing in main

-or-


struct mystructname{
//members here
};
and then in main()
struct mystructname mystructarray[50];

If you make it in main, you're going to have to pass a copy of the struct into your methods (and keep track of the number of entries out in main). If you make it in the first way the array of structs is global and you can access it directly. The first way is probably neater and preferable.

However: I'm looking back over your code and noticing that you aren't really trying to keep an array of the names and addresses at all. It seems like you might not even need the struct. If you need to keep it as part of your requirements just put:

struct addressbook{
//other members here
}myaddressbook;

and rename all of your references to addressbook in Insert() etc to myaddressbook. Apologies we got you going on this array route. I just didn't understand that all you were doing was populating the struct and then writing it out as raw strings anyway.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Then,

fin >> size;

fin >> size;
This will try to copy the value of fin, which is an ifstream variable to size. What is the use of that?

I think I know that one. I believe the first line in the file is an integer with the number of entries forthcoming. I do agree with you that the entire program is very confusing.

@OP: There's a lot of excess creation and deletion of variables that is not necessary with the proper passing. Another quick hint for you is that when you have (*temp).something it can be written as temp->something . However in this case I think you may be better off just addressing the elements using the array notation, e.g., pc.price.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

At what point do you get the seg fault?

One hint is that your filename is not making it into your readin function at all. You've appeased the compiler by redeclaring it but there's nothing in it. I suspect there are other areas as well. If you're going to use the ol-fashioned char * strings it's best to use getline so you don't overrun your array.

Continuing, you don't have your parameters in your definition of readin() laid out properly on line 34. They need to have names and the names must match what you are using in the function (so your int parameter could be called size) and not redeclared there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you give a sample input/output session (a limited one)? Also, your variable declarations should all be at the top of a block (e.g., at the top of main()) in order to be standard.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Wrap from lines 6 thru (and including) 43 in a do/while loop. Instead of having the if and else if use c == 'y' as your condition of your do/while.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Learn just a smidgen about wavelet transformations. Those are used in image processing and denoising methods of all kinds. Next time, though, try to search more extensively on the net because you couldn't possibly have missed something like numerical integration.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is value equal to when you enter into your function? The answer is any random bytes that happened to fall into that region all interpreted as a float. I know you've seen this issue before in other threads.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If a number that you pick up is higher than all the other numbers, does it matter what the other numbers are? If a number that you pick up is smaller than all the others that you have does it matter what the higher numbers are (with the exception of the max)? Looping is the right idea but realize what you need to keep track of is important.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a closer look at your index on your b.data_ vector on line 15.
The pattern that you have is this:

i,j,index of A,index of B
0,1 0 0
0,2 2 1
1,1 1 0
1,2 3 1
2,1 0 1
2,2 2 2
3,1 1 1
3,2 3 2

Now if you go through the calculation by hand that's not the right order for the i = 2 and 3's (it happens to work for the i = 0 and i = 1 cases)
For those you need something like this:

i,j,index of A,index of B
2,1 0 2
2,2 2 3
3,1 1 2
3,2 3 3

See what you get for the equation and then we can compare.

Also, you need to clear copy before each time you go through the js, that's why your answers were so high.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Unless I misread what you need I think you are complicating things a bit more than needed. Try something like the following (I'll let you flesh it out):

for (int i = 0;p_cString[i] !='\0';i++)
	if(p_cString[i] == valueToFind)
	{

Since you know the length of your string you could use that as a limit on i also. This way you can display to the user the number of timse the character came up and its position each time.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is this->Controls->Add(color);?
What will happen if code below is without this->Controls->Add(color);?
What is the result from the code this->Controls->Add(color);?

This statement actually adds the button you have created to the set of controls(buttons, listboxes, etc) that are associate with your window. Without it you won't have access to this control on your form, in effect your button won't exist at all. The result is you have a "color" button on your form to do whatever a color button does.