Method: CsrMatrix::Functions#trace

Defined in:
lib/csrmatrix/functions.rb

#traceObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# 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