Source code for optalg.lin_solver.lin_solver

#****************************************************#
# This file is part of OPTALG.                       #
#                                                    #
# Copyright (c) 2015-2016, Tomas Tinoco De Rubira.   #
#                                                    #
# OPTALG is released under the BSD 2-clause license. #
#****************************************************#

[docs]class LinSolver: # Class constants SYMMETRIC = 'symmetric' UNSYMMETRIC = 'unsymmetric' def __init__(self, prop='unsymmetric'): """ Linear solver class. Parameters ---------- prop : {``symmetric``, ``unsymmetric``} """ # Check if prop not in [self.SYMMETRIC,self.UNSYMMETRIC]: raise ValueError('invalid property') #: Name (string) self.name = '' #: Linear system property {``'symmetric'``, ``'unsymmetric'``}. self.prop = prop #: Flag that specifies whether the matrix has been analyzed. self.analyzed = False
[docs] def is_analyzed(self): """ Determine whether the matrix has been analyzed. Returns ------- flags : {``True``, ``False``} """ return self.analyzed
[docs] def analyze(self, A): """ Analyzes structure of A. Parameters ---------- A : matrix """ self.analyzed = True
[docs] def factorize(self, A): """ Factorizes A. Parameters ---------- A : matrix """ pass
[docs] def solve(self, b): """ Solves system Ax=b. Parameters ---------- b: vector Returns ------- x : vector """ return None
[docs] def factorize_and_solve(self, A, b): """ Factorizes A and solves Ax=b. Returns ------- x : vector """ self.factorize(A) return self.solve(b)