Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Combining arrays into matrix

  1. Sep 23, 2009 #1
    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.
     
  2. jcsd
  3. Sep 23, 2009 #2
    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)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Combining arrays into matrix
  1. C++ Array (Replies: 10)

  2. C# arrays (Replies: 1)

  3. Array storage (Replies: 1)

Loading...