module CsrMatrix::Functions
Constants
- C
Public Class Methods
included(exceptions)
click to toggle source
# File lib/csrmatrix/functions.rb, line 7 def self.included(exceptions) exceptions.send :include, Exceptions end
Public Instance Methods
det()
click to toggle source
# File lib/csrmatrix/functions.rb, line 25 def det() # alias for determinant # identifies the determinant of a matrix is_invariant? return self.determinant() end
determinant()
click to toggle source
# File lib/csrmatrix/functions.rb, line 12 def determinant() # identifies the determinant of a matrix is_invariant? if !self.square?() raise Exceptions::MatrixDimException.new, "Matrix is not square." return false end m = Matrix.rows(self.decompose) return m.det() end
rank()
click to toggle source
# File lib/csrmatrix/functions.rb, line 33 def rank() # identifies the rank of a matrix is_invariant? m = Matrix.rows(self.decompose) return m.rank() end
round(ndig = 0)
click to toggle source
FIXME: I’m not sure whats going on here?
# File lib/csrmatrix/functions.rb, line 41 def round(ndig = 0) # identifies the round of a matrix (that is, each value rounded by a specific degree) # pre integer of degree, existing matrix (matrix.not_null?) is_invariant? # post rounded array for i in 0..self.val.count-1 self.val[i] = self.val[i].round(ndig) end self.val end
tr()
click to toggle source
# File lib/csrmatrix/functions.rb, line 69 def tr() # alias for trace # identifies the trace of the matrix is_invariant? return self.trace() end
trace()
click to toggle source
# File lib/csrmatrix/functions.rb, line 53 def trace() # identifies the trace of the matrix is_invariant? sum = 0 for i in 0..self.columns-1 for j in self.row_ptr[i]..self.row_ptr[i+1]-1 if self.col_ind[j] == i sum += self.val[j] break end end end return sum end