Can arrays be combined into a matrix for more efficient coding?

  • Thread starter Thread starter andykol
  • Start date Start date
  • Tags Tags
    Arrays Matrix
AI Thread Summary
The discussion revolves around the possibility of combining two single-dimensional arrays into a two-dimensional matrix while maintaining the same computational results. The user inquires if they can modify their program to achieve this, specifically asking how to structure the matrix so that it correctly multiplies the intended elements. A suggestion is made to represent the operation as M = P * A(1,X) + Q * A(2,Y), clarifying that A(1,Y) corresponds to A(1) and B(X,2) corresponds to B(2). However, it is noted that transitioning to a two-dimensional array may not reduce memory utilization; in fact, using a one-dimensional array format is suggested as a more memory-efficient alternative.
andykol
Messages
9
Reaction score
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.
 
Technology news on Phys.org
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)
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top