File: RecoveryCore.cpp

package info (click to toggle)
colpack 1.0.10-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,704 kB
  • sloc: cpp: 49,807; ansic: 1,231; makefile: 419; sh: 13
file content (134 lines) | stat: -rw-r--r-- 3,344 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/************************************************************************************
    Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
    Alex Pothen

    This file is part of ColPack.

    ColPack is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ColPack is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with ColPack.  If not, see <http://www.gnu.org/licenses/>.
************************************************************************************/

#include "ColPackHeaders.h"

using namespace std;

namespace ColPack
{
	RecoveryCore::RecoveryCore() {
		//formatType = "UNKNOWN";

		//for ADOL-C Format (AF)
		AF_available = false;
		i_AF_rowCount = 0;
		dp2_AF_Value = NULL;

		//for Sparse Solvers Format (SSF)
		SSF_available = false;
		i_SSF_rowCount = 0;
		ip_SSF_RowIndex = NULL;
		ip_SSF_ColumnIndex = NULL;
		dp_SSF_Value = NULL;

		//for Coordinate Format (CF)
		CF_available = false;
		i_CF_rowCount = 0;
		ip_CF_RowIndex = NULL;
		ip_CF_ColumnIndex = NULL;
		dp_CF_Value = NULL;
	}

	void RecoveryCore::reset() {

		//for ADOL-C Format (AF)
		if (AF_available) {
			//free_2DMatrix(dp2_AF_Value, i_AF_rowCount);
			for( int i=0; i < i_AF_rowCount; i++ ) {
			    free( dp2_AF_Value[i] );
			}
			free( dp2_AF_Value );

			dp2_AF_Value = NULL;
			AF_available = false;
			i_AF_rowCount = 0;
		}

		//for Sparse Solvers Format (SSF)
		if (SSF_available) {
			//delete[] ip_SSF_RowIndex;
			free(ip_SSF_RowIndex);
			ip_SSF_RowIndex = NULL;
			//delete[] ip_SSF_ColumnIndex;
			free(ip_SSF_ColumnIndex);
			ip_SSF_ColumnIndex = NULL;
			//delete[] dp_SSF_Value;
			free(dp_SSF_Value);
			dp_SSF_Value = NULL;
			SSF_available = false;
			i_SSF_rowCount = 0;
		}

		//for Coordinate Format (CF)
		if (CF_available) {
			//do something
			//delete[] ip_CF_RowIndex;
			free(ip_CF_RowIndex);
			ip_CF_RowIndex = NULL;
			//delete[] ip_CF_ColumnIndex;
			free(ip_CF_ColumnIndex);
			ip_CF_ColumnIndex = NULL;
			//delete[] dp_CF_Value;
			free(dp_CF_Value);
			dp_CF_Value = NULL;
			CF_available = false;
			i_CF_rowCount = 0;
		}

		//formatType = "UNKNOWN";
	}

	RecoveryCore::~RecoveryCore() {

		//for ADOL-C Format (AF)
		if (AF_available) {
			//do something
			//free_2DMatrix(dp2_AF_Value, i_AF_rowCount);

			for( int i=0; i < i_AF_rowCount; i++ ) {
			    free( dp2_AF_Value[i] );
			}
			free( dp2_AF_Value );
		}

		//for Sparse Solvers Format (SSF)
		if (SSF_available) {
			//do something
			//delete[] ip_SSF_RowIndex;
			free(ip_SSF_RowIndex);
			//delete[] ip_SSF_ColumnIndex;
			free(ip_SSF_ColumnIndex);
			//delete[] dp_SSF_Value;
			free(dp_SSF_Value);
		}

		//for Coordinate Format (CF)
		if (CF_available) {
			//do something
			//delete[] ip_CF_RowIndex;
			free(ip_CF_RowIndex);
			//delete[] ip_CF_ColumnIndex;
			free(ip_CF_ColumnIndex);
			//delete[] dp_CF_Value;
			free(dp_CF_Value);
		}
	}
}