$search
00001 /* 00002 * OpenNL: Numerical Library 00003 * Copyright (C) 2004 Bruno Levy 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 * 00019 * If you modify this software, you should include a notice giving the 00020 * name of the person performing the modification, the date of modification, 00021 * and the reason for such modification. 00022 * 00023 * Contact: Bruno Levy 00024 * 00025 * levy@loria.fr 00026 * 00027 * ISA Project 00028 * LORIA, INRIA Lorraine, 00029 * Campus Scientifique, BP 239 00030 * 54506 VANDOEUVRE LES NANCY CEDEX 00031 * FRANCE 00032 * 00033 * Note that the GNU General Public License does not permit incorporating 00034 * the Software into proprietary programs. 00035 */ 00036 00037 #ifndef __NL_CONTEXT__ 00038 #define __NL_CONTEXT__ 00039 00040 #include <NL/nl_private.h> 00041 #include <NL/nl_matrix.h> 00042 00043 /************************************************************************************/ 00044 /* NLContext data structure */ 00045 00046 typedef void(*NLMatrixFunc)(double* x, double* y) ; 00047 typedef NLboolean(*NLSolverFunc)() ; 00048 00049 typedef struct { 00050 NLdouble value ; 00051 NLboolean locked ; 00052 NLuint index ; 00053 } NLVariable ; 00054 00055 #define NL_STATE_INITIAL 0 00056 #define NL_STATE_SYSTEM 1 00057 #define NL_STATE_MATRIX 2 00058 #define NL_STATE_ROW 3 00059 #define NL_STATE_MATRIX_CONSTRUCTED 4 00060 #define NL_STATE_SYSTEM_CONSTRUCTED 5 00061 #define NL_STATE_SOLVED 6 00062 00063 typedef struct { 00064 NLenum state ; 00065 NLVariable* variable ; 00066 NLuint n ; 00067 NLSparseMatrix M ; 00068 NLRowColumn af ; 00069 NLRowColumn al ; 00070 NLRowColumn xl ; 00071 NLdouble* x ; 00072 NLdouble* b ; 00073 NLdouble right_hand_side ; 00074 NLdouble row_scaling ; 00075 NLenum solver ; 00076 NLenum preconditioner ; 00077 NLuint nb_variables ; 00078 NLuint current_row ; 00079 NLboolean least_squares ; 00080 NLboolean symmetric ; 00081 NLuint max_iterations ; 00082 NLuint inner_iterations ; 00083 NLdouble threshold ; 00084 NLdouble omega ; 00085 NLboolean normalize_rows ; 00086 NLboolean alloc_M ; 00087 NLboolean alloc_af ; 00088 NLboolean alloc_al ; 00089 NLboolean alloc_xl ; 00090 NLboolean alloc_variable ; 00091 NLboolean alloc_x ; 00092 NLboolean alloc_b ; 00093 NLuint used_iterations ; 00094 NLdouble error ; 00095 NLdouble elapsed_time ; 00096 NLMatrixFunc matrix_vector_prod ; 00097 NLMatrixFunc precond_vector_prod ; 00098 NLSolverFunc solver_func ; 00099 } NLContextStruct ; 00100 00101 extern NLContextStruct* nlCurrentContext ; 00102 00103 void nlCheckState(NLenum state) ; 00104 void nlTransition(NLenum from_state, NLenum to_state) ; 00105 00106 void nlMatrixVectorProd_default(NLdouble* x, NLdouble* y) ; 00107 NLboolean nlDefaultSolver() ; 00108 00109 #endif