Combining arrays into matrix

  • Thread starter andykol
  • Start date
  • #1
9
0
Hello,

Currently I have two single dimension arrays. I am interested to know if I can modify program by combining them to a matrix giving same result.
E.g.
A(X), B(Y) used for M=P*A(1)+Q*B(2)
Proposed-
A(X,Y) used for M=P*A(1,Y)+Q*B(X,2)
Program should understand that it has to multiply only X value of A to P.
where A(1,Y)=A(1), B(X,2)=B(2)

Is it possible to do like this? if yes, the how? also whether it can reduce memory utilisation?

Thanks in advance.
 

Answers and Replies

  • #2
887
98
Do you want to combine two separate single dimensioned arrays into one two dimensional array? If not, then I don't understand your question. But if so, then it could look like this: M = P * A(1,X) + Q * A(2,Y) where A(1,X) = A(X) and A(2,Y) = B(Y)

I don't think it will reduce memory utilization. However, dimensioning your array to 1 instead of 2 will reduce memory usage: M = P * A(0) + Q * B(1) or for the two dimensional version M = P * A(0,X) + Q * A(1,Y)
 

Related Threads on Combining arrays into matrix

Replies
3
Views
2K
Replies
4
Views
645
  • Last Post
Replies
16
Views
3K
  • Last Post
2
Replies
33
Views
2K
Replies
21
Views
1K
Replies
3
Views
3K
Replies
3
Views
2K
Replies
4
Views
46K
Top