system
#1
I’ve been trying to make a fast function but im running into a strange casting problem…
#define Divisor1 4
byte W[5] = {0,0,0,0,0};
byte Input[1] = {0};
byte Output[1];
word Accum;
word temp;
byte i,o;
void setup(){
Serial.begin(115200);
}
void loop(){}
void sigmoid()//add code to specify which output and weight set, but not for benchmarks
{
for(i = 0; i<5; i++)
{ Accum += ((W[i] * Input[i])/Divisor1);
Output = (byte)(Accum/255);
//or
// temp = (Accum/255);
// Output= (byte)temp;
}
}
and the error messages, same either way
sketch_jul31a.ino: In function 'void sigmoid()':
sketch_jul31a:31: error: incompatible types in assignment of 'byte' to 'byte [1]'
I’m obviously missing something…=)
does anyone know why this is happening and if you do, a workaround?
thanks
–Isaac
'Output' is an array and an rvalue, you cannot assign to it.
To index a particular element of Output, use the sub script operators:
Output[ 0 ] = (byte)(Accum/255);
Why is it an array of size one. Its only useful if a function you use requires an array. Why not just a plain old byte.
Output [0]= (byte)(Accum/255);
system
#4
I’ve been trying to make a fast function but im running into a strange casting problem…
#define Divisor1 4
byte W[5] = {0,0,0,0,0};
byte Input[1] = {0};
byte Output[1];
word Accum;
word temp;
byte i,o;
void setup(){
Serial.begin(115200);
}
void loop(){}
void sigmoid()//add code to specify which output and weight set, but not for benchmarks
{
for(i = 0; i<5; i++)
{ Accum += ((W[i] * Input[i])/Divisor1);
Output = (byte)(Accum/255);
//or
// temp = (Accum/255);
// Output= (byte)temp;
}
}
and the error messages, same either way
sketch_jul31a.ino: In function 'void sigmoid()':
sketch_jul31a:31: error: incompatible types in assignment of 'byte' to 'byte [1]'
I’m obviously missing something…=)
does anyone know why this is happening and if you do, a workaround?
thanks
–Isaac
system
#5
Never mind!
cant assign a variable to a pointer!
thanks for your patience . 