00001
00018 #include "OSDataStructures.h"
00019 #include <iostream>
00020 using std::cout;
00021 using std::endl;
00022
00023 SparseVector::SparseVector( int number_):
00024 number( number_)
00025 {
00026 indexes = new int[ number];
00027 values = new double[ number];
00028 bDeleteArrays = true;
00029 }
00030
00031
00032 SparseVector::SparseVector( ):
00033 bDeleteArrays(true),
00034 indexes( NULL),
00035 values( NULL)
00036 {
00037 }
00038
00039 SparseVector::~SparseVector(){
00040 #ifdef DEBUG
00041 cout << "inside sparseVector destructor" << endl;
00042 #endif
00043 if( bDeleteArrays == true){
00044 delete[] indexes;
00045 delete[] values;
00046 }
00047 values = NULL;
00048 indexes = NULL;
00049 }
00050
00051 SparseMatrix::SparseMatrix():
00052 bDeleteArrays( true),
00053 isColumnMajor(true),
00054 startSize(0),
00055 valueSize(0),
00056 starts(NULL),
00057 indexes(NULL),
00058 values(NULL)
00059 {
00060 }
00061
00062
00063
00064 SparseMatrix::SparseMatrix(bool isColumnMajor_, int startSize_, int valueSize_):
00065 isColumnMajor(isColumnMajor_),
00066 startSize(startSize_),
00067 valueSize(valueSize_)
00068 {
00069 bDeleteArrays = true;
00070 starts = new int[startSize];
00071 indexes = new int[valueSize];
00072 values = new double[valueSize];
00073
00074 }
00075
00076
00077 SparseMatrix::~SparseMatrix(){
00078 #ifdef DEBUG
00079 cout << "inside SparseMatrix destructor" << endl;
00080 #endif
00081 if( bDeleteArrays == true){
00082 delete[] starts;
00083 delete[] indexes;
00084 delete[] values;
00085
00086 }
00087 starts = NULL;
00088 indexes = NULL;
00089 values = NULL;
00090 }
00091
00092
00093 bool SparseMatrix::display(int secondaryDim){
00094 int i, j, k;
00095 for ( i = 0; i < startSize - 1; i++){
00096
00097 if (starts[i] == starts[i + 1]){
00098
00099 for ( k = 0; k < secondaryDim; k++){
00100
00101 }
00102 }
00103 else {
00104 for ( j = 0; j < indexes[starts[i]]; j ++){
00105
00106 }
00107
00108 for ( j = starts[ i ]; j < starts[i + 1]; j++){
00109
00110
00111
00112 if ( j < starts[i + 1] - 1){
00113 for ( k = indexes [j] + 1; k < indexes[j + 1]; k++){
00114
00115 }
00116 }
00117 else {
00118
00119 for ( k = indexes [j] + 1; k < secondaryDim; k++){
00120
00121 }
00122 }
00123 }
00124 }
00125
00126 }
00127
00128 return true;
00129
00130 }
00131
00132 SparseJacobianMatrix::SparseJacobianMatrix():
00133 bDeleteArrays( true),
00134 startSize(0),
00135 valueSize(0),
00136 starts(NULL),
00137 conVals(NULL),
00138 indexes(NULL),
00139 values(NULL)
00140 {
00141 }
00142
00143
00144 SparseJacobianMatrix::SparseJacobianMatrix(int startSize_, int valueSize_):
00145 bDeleteArrays( true),
00146 startSize(startSize_),
00147 valueSize(valueSize_)
00148 {
00149 starts = new int[startSize];
00150 conVals = new int[startSize];
00151 indexes = new int[valueSize];
00152 values = new double[valueSize];
00153 }
00154
00155
00156 SparseJacobianMatrix::~SparseJacobianMatrix(){
00157 #ifdef DEBUG
00158 cout << "inside SparseJacobianMatrix destructor" << endl;
00159 #endif
00160 if(bDeleteArrays == true){
00161 #ifdef DEBUG
00162 cout << "delete SparseJacobianArrays" << endl;
00163 #endif
00164 delete[] starts;
00165 delete[] conVals;
00166 delete[] indexes;
00167 delete[] values;
00168 }
00169 starts = NULL;
00170 conVals = NULL;
00171 indexes = NULL;
00172 values = NULL;
00173 }
00174
00175
00176 SparseHessianMatrix::SparseHessianMatrix():
00177 bDeleteArrays( true),
00178 hessDimension(0),
00179 hessRowIdx( NULL),
00180 hessColIdx( NULL),
00181 hessValues( NULL)
00182 {
00183 }
00184
00185
00186
00187 SparseHessianMatrix::~SparseHessianMatrix(){
00188 #ifdef DEBUG
00189 cout << "inside SparseJacobianMatrix destructor" << endl;
00190 #endif
00191 if(bDeleteArrays == true){
00192 delete[] hessRowIdx;
00193 delete[] hessColIdx;
00194 delete[] hessValues;
00195 }
00196 hessRowIdx = NULL;
00197 hessColIdx = NULL;
00198 hessValues = NULL;
00199 }
00200
00201
00202
00203 QuadraticTerms::QuadraticTerms():
00204 rowIndexes(NULL),
00205 varOneIndexes(NULL),
00206 varTwoIndexes(NULL),
00207 coefficients(NULL)
00208 {
00209 }
00210
00211 QuadraticTerms::~QuadraticTerms(){
00212 #ifdef DEBUG
00213 cout << "inside Quadratic Terms destructor" << endl;
00214 #endif
00215 delete[] rowIndexes;
00216 rowIndexes = NULL;
00217 delete[] varOneIndexes;
00218 varOneIndexes = NULL;
00219 delete[] varTwoIndexes;
00220 varTwoIndexes = NULL;
00221 delete[] coefficients;
00222 coefficients = NULL;
00223 }
00224
00225
00226 IntVector::IntVector():
00227 el(NULL)
00228 {
00229 #ifdef DEBUG
00230 cout << "Inside the IntVector Constructor" << endl;
00231 #endif
00232 }
00233
00234 IntVector::~IntVector(){
00235 #ifdef DEBUG
00236 cout << "Inside the IntVector Destructor" << endl;
00237 #endif
00238 delete[] el;
00239 el = NULL;
00240 }
00241
00242 DoubleVector::DoubleVector():
00243 el(NULL)
00244 {
00245 #ifdef DEBUG
00246 cout << "Inside the DoubleVector Constructor" << endl;
00247 #endif
00248
00249 }
00250
00251
00252 DoubleVector::~DoubleVector(){
00253 #ifdef DEBUG
00254 cout << "Inside the DoubleVector Destructor" << endl;
00255 #endif
00256 delete[] el;
00257 el = NULL;
00258 }
00259