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