00001 /*************************************************************************** 00002 * Copyright (C) 2003-2004 by David Saxton * 00003 * david@bluehaze.org * 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 00011 #ifndef ELEMENTSET_H 00012 #define ELEMENTSET_H 00013 00014 #include <qvaluelist.h> 00015 //#include <vector> 00016 00017 //using namespace std; 00018 00019 class CBranch; 00020 class Circuit; 00021 class CNode; 00022 class Element; 00023 class ElementSet; 00024 class LogicIn; 00025 class Matrix; 00026 class NonLinear; 00027 00028 #include "math/qvector.h" 00029 00030 typedef QValueList<Element*> ElementList; 00031 typedef QValueList<NonLinear*> NonLinearList; 00032 00033 //typedef vector<CBranch> CBranchList_T; 00034 00050 class ElementSet 00051 { 00052 public: 00058 ElementSet(Circuit *circuit, const int n, const int m); 00063 ~ElementSet(); 00064 Circuit *circuit() const { return m_pCircuit; } 00065 void addElement( Element *e ); 00066 void setCacheInvalidated(); 00071 Matrix *matrix() const { return p_A; } 00075 QuickVector *b() const { return p_b; } 00079 QuickVector *x() const { return p_x; } 00080 void set_x(QuickVector *x) { delete p_x; p_x = x; } 00084 bool containsNonLinear() const { return b_containsNonLinear; } 00089 void doNonLinear( int maxIterations, double maxErrorV = 1e-9, double maxErrorI = 1e-12 ); 00094 bool doLinear( bool performLU ); 00095 00096 CBranch *cbranches(const unsigned i) { return m_cbranches[i]; } 00097 CNode *cnodes(const unsigned i) { return m_cnodes[i]; } 00098 CNode *ground() const { return m_ground; } 00099 00103 int cnodeCount() const { return m_cn; } 00104 00108 int cbranchCount() const { return m_cb; } 00109 // int cbranchCount() const { return m_cbranches->size(); } 00110 00111 void createMatrixMap(); 00115 void displayEquations(); 00119 void updateInfo(); 00120 00121 private: 00122 // calc enginge stuff 00123 Matrix *p_A; 00124 QuickVector *p_x; 00125 QuickVector *p_b; 00126 // end calc engine stuff. 00127 00128 ElementList m_elementList; 00129 NonLinearList m_cnonLinearList; 00130 00131 uint m_cb; // # cbranches 00132 CBranch **m_cbranches; // Pointer to an array of cbranches 00133 00134 // CBranchList_T *m_cbranches; 00135 00136 uint m_cn; // # cnodes 00137 CNode **m_cnodes; // Pointer to an array of cnodes 00138 CNode *m_ground; 00139 00140 uint m_clogic; 00141 LogicIn **p_logicIn; 00142 bool b_containsNonLinear; 00143 Circuit *m_pCircuit; 00144 }; 00145 00146 #endif 00147
1.5.1