The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 use of float[]
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

eprlab

USA
5 Posts

Posted - 08/27/2003 :  3:14:25 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I am using an array (float fit[4096]) in my Origin C code. I also pass this array to a few functions. I noticed that the array does not store the resultant values. Is it because I should be passing a vector to a function?

Also, I use many more arrays similar to the one above. Though I do not get any compilation errors, I am not sure about the usage with such a declaration.

EPR

cpyang

USA
1406 Posts

Posted - 08/27/2003 :  3:57:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Array should work, need to see code example to see what can be wrong. It is much better to use vector, as it can be resized and you can directly do vector arithmetics on vectors, like

void my_add_func(vector<float>& vv, double factor)
{
// just some calculation
for(int ii = 0; ii < vv.GetSize(); ii++)
vv[ii] += factor + 0.01 * ii;
}

void main()
{
vector<float> fit(4096);
fit = 0;// set all 4096 elements to 0;

my_add_func(fit, 10);
printf("1st val = %f, last val = %f\n", fit[0], fit[4095]);
}


CP


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000