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