I am trying to convert my Matlab code to C++ using Eigen library and I am stuck at the part where I have to initialise a 3 dimensional variable SMat (order of 26x10x181) with data type double from a 2 dimensional variable S (order of 10x181).Also I seem to get error where I need to perform scalar with vector multiplication of Freq(order 26x1) and delay(181x10). I am confused on how to represent delay(angle,:)
,S(:,angle)
and StMat(iFreq,:,angle)
as given in the matlab code below, using Eigen library inside for loops
.
for freqBin=1:26
for angle=1:181
S(:,angle)=exp(-1i*(Freq(freqBin).*delay(angle,:)')); %1st command
end
SMat(freqBin,:,:)=S;%2nd command
end
%%
for freqBin=1:26
for angle=1:181
StM(:,1) = StMat(iFreq,:,angle);%3rd command---- order of StM 10x1
In my C++ code , Freq is of data type VectorXd (since I used setLinspaced() for its definition) and delay is of data type MatrixXd. I tried to use .cwiseProduct() but it resulted in error.I referrred to this site, but the output of the example mentioned gave me a 5x5 matrix full of 47. The effect of 10 is not visible. Can anyone suggest me a command for element by element multiplication and initialisation of 3D matrix?Please help.