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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 use of float[]

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
eprlab Posted - 08/27/2003 : 3:14:25 PM
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
1   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 08/27/2003 : 3:57:53 PM
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



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000