/home/coin/SVN-release/Ipopt-3.3.2/Ipopt/src/Algorithm/LinearSolvers/IpTAUCSSolverInterface.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2005, Yifan Hu (Wolfram Research) and others
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // $Id: IpTAUCSSolverInterface.hpp 759 2006-07-07 03:07:08Z andreasw $
00006 //
00007 // Author:  Yifan Hu              2005-04-06
00008 
00009 #ifndef __IPTAUCSSOLVERINTERFACE_HPP__
00010 #define __IPTAUCSSOLVERINTERFACE_HPP__
00011 
00012 #include "IpSparseSymLinearSolverInterface.hpp"
00013 
00014 extern "C"
00015 {
00016 # include <taucs.h>
00017 
00018   void  taucs_free_stub(void *ptr);
00019   void  taucs_free   (void* ptr);
00020 # define taucs_free(x)      taucs_free_stub(x)
00021 
00022   void* taucs_malloc_stub(size_t size);
00023   void* taucs_malloc (size_t size);
00024 # define taucs_malloc(x)    taucs_malloc_stub(x);
00025 }
00026 
00027 namespace Ipopt
00028 {
00029 
00034   class TAUCSSolverInterface: public SparseSymLinearSolverInterface
00035   {
00038     enum TAUCS_Matrix_type {
00039       TAUCS_FACTORTYPE_NONE,
00040       TAUCS_FACTORTYPE_LLT_SUPERNODAL,
00041       TAUCS_FACTORTYPE_LLT_CCS,
00042       TAUCS_FACTORTYPE_IND
00043     };
00044 
00046     typedef struct
00047     {
00048       int n;
00049       int flags;
00050       TAUCS_Matrix_type type;
00051       int* rowperm;
00052       int* colperm;
00053       void* L;
00054     }
00055     taucs_factorization;
00056 
00057   public:
00061     TAUCSSolverInterface();
00062 
00064     virtual ~TAUCSSolverInterface();
00066 
00068     bool InitializeImpl(const OptionsList& options,
00069                         const std::string& prefix);
00070 
00071 
00075     virtual ESymSolverStatus InitializeStructure(Index dim, Index nonzeros,
00076         const Index *ia,
00077         const Index *ja);
00078 
00081     virtual double* GetValuesArrayPtr();
00082 
00084     virtual ESymSolverStatus MultiSolve(bool new_matrix,
00085                                         const Index* ia,
00086                                         const Index* ja,
00087                                         Index nrhs,
00088                                         double* rhs_vals,
00089                                         bool check_NegEVals,
00090                                         Index numberOfNegEVals);
00091 
00095     virtual Index NumberOfNegEVals() const;
00097 
00098     //* @name Options of Linear solver */
00100 
00102     virtual bool IncreaseQuality();
00103 
00107     virtual bool ProvidesInertia() const
00108     {
00109       return true;
00110     }
00114     EMatrixFormat MatrixFormat() const
00115     {
00116       return CSR_Format_0_Offset;
00117     }
00119 
00120   private:
00130     TAUCSSolverInterface(const TAUCSSolverInterface&);
00131 
00133     void operator=(const TAUCSSolverInterface&);
00135 
00139     Index n_;
00140 
00142     Index nz_;
00143 
00145     double* a_;
00146 
00149     bool multi_frontal_;
00150 
00152     taucs_factorization *taucs_factor_;
00153 
00155     taucs_ccs_matrix *A_;
00157 
00161     Index negevals_;
00162 
00165     bool initialized_;
00167 
00171     ESymSolverStatus SymbolicFactorization(const Index* ia,
00172                                            const Index* ja);
00173 
00175     ESymSolverStatus Factorization(const Index* ia,
00176                                    const Index* ja,
00177                                    bool check_NegEVals,
00178                                    Index numberOfNegEVals);
00179 
00181     ESymSolverStatus Solve(const Index* ia,
00182                            const Index* ja,
00183                            Index nrhs,
00184                            double *rhs_vals);
00185 
00187     int element_size(int flags)
00188     {
00189       if (flags & TAUCS_SINGLE)
00190         return sizeof(taucs_single);
00191       if (flags & TAUCS_DOUBLE)
00192         return sizeof(taucs_double);
00193       if (flags & TAUCS_SCOMPLEX)
00194         return sizeof(taucs_scomplex);
00195       if (flags & TAUCS_DCOMPLEX)
00196         return sizeof(taucs_dcomplex);
00197       if (flags & TAUCS_INT)
00198         return sizeof(int);
00199       return -1;
00200     }
00201 
00203     void taucs_factor_delete_L(taucs_factorization *F);
00204 
00206     void taucs_delete(taucs_factorization *F, taucs_ccs_matrix *A);
00208   };
00209 
00210 } // namespace Ipopt
00211 #endif

Generated on Thu May 15 22:27:52 2008 by  doxygen 1.4.7