Exemple #1
0
 def __mul__(self, other):
     if isinstance(other, Number):
         return Matrix(API.scalarMultiply(self._matrix, other))
     elif isinstance(other, Vector):
         return Vector(API.operate(self._matrix, other._vector))
     else:
         return Matrix(API.multiply(self._matrix, other._matrix))
Exemple #2
0
 def __init__(self, mat):
     self._dec = API.newSingularValueDecompositionImpl(mat._matrix)
Exemple #3
0
 def __sub__(self, other):
     if isinstance(other, Number):
         return Matrix(API.scalarAdd(self._matrix, -other))
     else:
         return Matrix(API.subtract(self._matrix, other._matrix))
Exemple #4
0
 def init_fromsize(self, rows, columns):
     self._matrix = API.newArray2DRowRealMatrix(rows, columns)
Exemple #5
0
 def norm(self):
     return API.getNorm(self._vector)
Exemple #6
0
 def __setitem__(self, i, val):
     if 0 <= i < len(self):
         API.setEntry(self._vector, i, val)
     else:
         raise IndexError
Exemple #7
0
 def __mul__(self, other):
     if isinstance(other, Number):
         return Vector(API.mapMultiply(self._vector, other))
     else:
         return Vector(API.dotProduct(self._vector, other._vector))
Exemple #8
0
 def __add__(self, other):
     return Vector(API.add(self._vector, other._vector))
Exemple #9
0
 def rows(self):
     return API.getRowDimension(self._matrix)
Exemple #10
0
 def increment(self, i, j, val):
     API.addToEntry(self._matrix, i, j, val)
Exemple #11
0
 def __getitem__(self, ij):
     i, j = ij
     return API.getEntry(self._matrix, i, j)
Exemple #12
0
 def __setitem__(self, ij, val):
     i, j = ij
     API.setEntry(self._matrix, i, j, val)
Exemple #13
0
 def __pow__(self, n):
     return Matrix(API.power(self._matrix, n))
Exemple #14
0
 def __init__(self):
     self._vector = API.newArrayRealVector()
Exemple #15
0
 def columns(self):
     return API.getColumnDimension(self._matrix)
Exemple #16
0
 def init_fromlist(self, data):
     self._vector = API.newArrayRealVector(data)
Exemple #17
0
 def norm(self):
     return API.getNorm(self._matrix)
Exemple #18
0
 def __sub__(self, other):
     return Vector(API.subtract(self._vector, other._vector))
Exemple #19
0
 def trace(self):
     return API.getTrace(self._matrix)
Exemple #20
0
 def __getitem__(self, i):
     if 0 <= i < len(self):
         return API.getEntry(self._vector, i)
     else:
         raise IndexError
Exemple #21
0
 def solve_matrix(self, mat):
     return Matrix(API.solve(self._solver, mat._matrix))
Exemple #22
0
 def __len__(self):
     return API.getDimension(self._vector)
Exemple #23
0
 def solve_vector(self, vec):
     return Vector(API.solve(self._solver, vec._vector))
Exemple #24
0
 def __init__(self):
     self._matrix = API.newArray2DRowRealMatrix()
Exemple #25
0
 def solver(self):
     try:
         solver = self._solver
     except AttributeError:
         solver = self._solver = Solver(API.getSolver(self._dec))
     return solver
Exemple #26
0
 def init_fromdata(self, data):
     self._matrix = API.newArray2DRowRealMatrix(data)
Exemple #27
0
 def __add__(self, other):
     if isinstance(other, Number):
         return Matrix(API.scalarAdd(self._matrix, other))
     else:
         return Matrix(API.add(self._matrix, other._matrix))