 # Matrix outpout

Hi all,
I have a problem. The result that i want to obtain is a matrix 2x2(note C). The parameter that i give to calculate the matrix C are a(n),b(n). So I want to obtains n matrix. What is the idea to do i?
Thank of avance

Hi camaptrang,

Sorry but I’m not quite sure what you’re asking. Are “a” and “b” linearized 2-D arrays where n=2 (2x2)? If so, then just take the normal matrix multiply algorithm and instead of accessing using a_[j], use a computed index “idx=i*2+j”.
\

• Mat_

Hi,
I’m sorry, I ased a question not clear. Example, I have n couple (a(i),b(i)),i=1,n. I want to calcul matrix A(mxk) n time. Example, at 1-th step, i have
A(i,j)=a(1)^ib(1)^j; i=1,…,m;j=1,…,n
.
.
.
at n-th step, i have
A(i,j)=a(n)^i
b(n)^j; i=1,…,m;j=1,…,n
The results which I want to obtains are n matrix A(mxk)
Thank you of avance.

What is k? There is no occurrence of k in the definitions of A(i,j) that you gave. Given that i=1:m and j=1:n, according to the definitions A is m x n, not m x k, unless k=n.

I am reminded of what one of my mathematics teachers used to drill into his students: “A problem well defined is a problem half solved”.

Hi,
A is a matrix of size mxk, then j=1,…,k. I had a mistake.
Thank you.

Sorry, still not quite understanding what question you’re asking. Do you need to sum A(i,j) n times?

``````  do i=1,m
do j=1,k
A(i,j) = 0.0
do n=1,n
A(i,j)=A(i,j) + a(n)**i * b(n)**j
enddo
enddo
enddo
``````
• Mat

Hi,
Thank you very much; I solved my problem.