Skip to content
jtprince edited this page Dec 2, 2010 · 1 revision

Convert from NArray to NMatrix

Consider making a reference to your NArray (i.e., shallow copy):

  narray = NArray[ [1,2,3], [4,5,6] ]
  nmatrix = NMatrix.ref( narray )

A deep copy can be made in one of three ways:

  narr = NArray[ [1,2,3], [4,5,6] ]
  # from slowest -> fastest & easiest -> hardest
  NMatrix[ *narr.to_a ]
  NMatrix.to_na( narr.to_a )
  NMatrix.to_na(narr.to_s, narr.typecode, *narr.shape)