View unanswered posts | View active topics It is currently Tue Sep 30, 2014 3:15 am






Reply to topic  [ 3 posts ] 
compiler:struct pass by value autom conv 2 pass by reference 
Author Message
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post compiler:struct pass by value autom conv 2 pass by reference
hi,
in the following code the compiler converts struct variables automatically to call by reference.

Actually, there is no need to do is - why is this happening?
Code:
const int nn = 100;
const int nd = 10;
const float thresh = 0.5;

typedef struct{
   float in[nd];
   float w[nd];
   float net;
   float t;
   float act;
   int out;
} tNeuron;


tNeuron Neuron[nn];

void initNeuron(tNeuron &neur){
   int d;

  for (d=0; d<nd; d++) {
    neur.in[d]=0;
    neur.w[d]=0;
  }
  neur.net=0;
  neur.t=thresh;
  neur.act=0;
  neur.out=0;
}

float netCalc(tNeuron neur){      // [31]
  int j=0;
  float s=0;

  for(j=0;j<nd;j++){
     s+= (neur.in[j]*neur.w[j]);
  }
  return s;
}

float actThr(tNeuron neur){     // [40]
   if (neur.act>=neur.t) return 1;
   else return 0;
}

Code:
[31] **Info***:Struct variable 'neur' automatically converted to call by reference
[40] **Info***:Struct variable 'neur' automatically converted to call by reference

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Wed Apr 16, 2008 3:24 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
anyone at home?
where is the support?

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Fri Apr 25, 2008 4:05 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
Reminder!

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Tue Apr 29, 2008 2:16 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.