i have a matrix :remember=Matrix[ ]
and this line remember[0,0]=3
why do i have this error at that line: undefined method `=' for
Matrix[]:Matrix (NoMethodError)
and how do i set values for my matrix only with one row
Hmm. It appears Matrix objects are supposed to be immutable. Use
arrays instead and convert to Matrix for matrix-type functions, so ...
require 'matrix'
=> true
require 'mathn' #need this for correct determinant calculations
=> true
a = [[1, 2], [3, 4]]
=> [[1, 2], [3, 4]]
a[0][0] = 3
=> [[3, 2], [3, 4]]
m = Matrix[*a]
=> Matrix[[3, 2], [3, 4]]
m.transpose
=> Matrix[[3, 3], [2, 4]]
m * m
=> Matrix[[15, 14], [21, 22]]
m_float = m.map {|i| i.to_f}
=> Matrix[[3.0, 2.0], [3.0, 4.0]]
m_inv = m_float.inverse
=> Matrix[[0.666666666666667, -0.333333333333333], [-0.5, 0.5]]
m.to_a
=> [[0.666666666666667, -0.333333333333333], [-0.5, 0.5]]
hth,
Todd
···
On 7/12/07, Bulhac Mihai <mihai.bulhac@yahoo.com> wrote: