I was looking to multiply two arrays together to get an output array containing
different proportions of the first 2 arrays which works as below.
void multScaleVV(arbb::dense& result,
arbb::dense in1, arbb::dense in2, arbb::f32 factor) {
arbb::f32 inv = 1.0 - factor;
result = (in1 * inv) + (in2 * factor);
return;
}
Then, I wanted to compile a 2D array by a 1D array (one line at a time where the
number of columns in the 2D array was the same as the size of the 1D array) similarly to
above. I thought I could re-use the above by writing something like below
void multScale(arbb::dense& result,
arbb::dense in1, arbb::dense in2, arbb::f32 factor) {
arbb::i32 i;
_for (i = 0, i < value(in2.num_rows()), i++) {
call(multScaleVV)(result.row(value(i)),in1,in2.row(value(i)),factor);
} _end_for
return;
}
But this will not compile. I eventually tracked it down to the result.row(value(i)) bit not returning
something that it could match to arbb::dense& (it wouldn't allow it to be modifiable)
So then I tried the version below
void multScale(arbb::dense& result,
arbb::dense in1, arbb::dense in2, arbb::f32 factor) {
arbb::dense tmpRes(in2.num_cols());
arbb::i32 i;
_for (i = 0, i < value(in2.num_rows()), i++) {
call(multScaleVV)(tmpRes,in1,in2.row(value(i)),factor);
result.row(value(i)) = tmpRes;
} _end_for
return;
}
Which won't compile as you can't use the result of locally allocated memory (or something similar). Is there
a straightforward solution to this that I am overlooking ?
--
jason



