Method: AppMath::Mat#to_1

Defined in:
lib/linalg.rb

#to_1Object

‘to one’. Returns a matrix with he same dimensions as self, but with all matrix elements set to 1.



866
867
868
869
870
871
872
873
874
875
# File 'lib/linalg.rb', line 866

def to_1
  d1 = dim1
  d2 = dim2
  fail "dim1 == 0" if d1.zero?
  fail "dim2 == 0" if d2.zero?
  fail "dim1 != dim2" unless d1 == d2
  unit = @x[0].x[0].to_1
  diag = Vec.new(d1,unit)
  Mat.new(diag)
end