The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Reshaping Arrays

SercoSteveB
Active Participant

What is Numeric Value Out following execution of the VI?

 

Reshaping Arrays.png

 

a) 12

b) 21

c) 27

d) 45

Comments
ersmt444
Member

Ans is B.

The thing should keep in mind is that the Reshape Array completes 1st row then second so on.Reshape Array work row-wise not column-wise.

In this case like this,

1           2

3           4

5           6

 

Hence addition is 21.

nik35324
Member

B

crossrulz
Knight of NI

B

 

Test tip here: All that really matters is that the first 6 elements are used.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
tlibro
Member

B

karthick@krishnan
Member

Member SercoSteveB

Ans : B

SercoSteveB
Active Participant

I am always interested when something doesn't behave like I expect. Does anybody know what rationale NI chose for the distribution of the original elements into the reshaped array?

MrStevenUND
Member

Had to look it up.  Always like when that happens.  

B.

crossrulz
Knight of NI

Rational:  I believe it comes from how the elements are actually stored in memory.  The array first consists of lengths, an I32 for each dimension.  After that, it is just the data elements.  In the case of a 2D array, each row is in order.  For example, and array of { {A,B,C},{D,E,F} } in memory is {3,2,A,B,C,D,E,F}.  So the reshape basically just changes the lengths (not quite as simple as that, but that is what I see in my head).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
mohamedtanveej17
Member

Thankz a lot @crossrulzz..

But I Still have confuse in that input side of reshape array..

All are answered with consider column and row manner but my doubt is why can't it will be row and column..and I just got a context help but it not mention that which one was row and a column so that maybe. C also be the answer..?

Certified LabVIEW Developer,
Project Engineer, HTIC IITM.
SercoSteveB
Active Participant

Answer: B.  Nice one all.  Thanks for the explanation crossrulz.