6 if( i<0 || j<0 ||
n<=i ||
n<=j ){
8 std::cerr <<
"The required component is out of the matrix size." << std::endl
9 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
n <<
"x" <<
n <<
"." << std::endl;
15 const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
17 const std::vector<CPPL_INT>::const_iterator line_ii_end =
line[ii].end();
18 for(std::vector<CPPL_INT>::const_iterator p=
line[ii].begin(); p!=line_ii_end; p++){
19 if(
data[*p].i==ii &&
data[*p].j==jj){
33 if( i<0 || j<0 ||
n<=i ||
n<=j ){
35 std::cerr <<
"The required component is out of the matrix size." << std::endl
36 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
n <<
"x" <<
n <<
"." << std::endl;
42 const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
44 const std::vector<CPPL_INT>::iterator line_ii_end =
line[ii].end();
45 for(std::vector<CPPL_INT>::iterator p=
line[ii].begin(); p!=line_ii_end; p++){
46 if(
data[*p].i==ii &&
data[*p].j==jj){
52 line[ii].push_back(CPPL_INT(
data.size()));
54 line[jj].push_back(CPPL_INT(
data.size()));
69 if( i<0 || j<0 ||
n<=i ||
n<=j ){
71 std::cerr <<
"The required component is out of the matrix size." << std::endl
72 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
n <<
"x" <<
n <<
"." << std::endl;
78 std::cerr <<
"The required component is already listed." << std::endl
79 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
85 const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
86 line[ii].push_back(CPPL_INT(
data.size()));
88 line[jj].push_back(CPPL_INT(
data.size()));
101 {CPPL_VERBOSE_REPORT;
103 if( i<0 || j<0 ||
n<=i ||
n<=j ){
105 std::cerr <<
"The required component is out of the matrix size." << std::endl
106 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
n <<
"x" <<
n <<
"." << std::endl;
111 const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
114 const std::vector<CPPL_INT>::iterator line_ii_end =
line[ii].end();
115 for(std::vector<CPPL_INT>::iterator p=
line[ii].begin(); p!=line_ii_end; p++){
116 if(
data[*p].i==ii &&
data[*p].j==jj){
119 CPPL_INT C =CPPL_INT(
data.size()-1);
128 const std::vector<CPPL_INT>::iterator line_jj_end =
line[jj].end();
129 for(std::vector<CPPL_INT>::iterator pj=
line[jj].begin(); pj!=line_jj_end; pj++){
130 if(*pj==c){
line[jj].erase(pj);
break; }
135 CPPL_INT I(data[c].i), J(data[c].j);
136 const std::vector<CPPL_INT>::iterator line_I_end =
line[I].end();
137 for(std::vector<CPPL_INT>::iterator q=
line[I].begin(); q!=line_I_end; q++){
138 if(*q==C){ *q=c;
break; }
141 const std::vector<CPPL_INT>::iterator line_J_end =
line[J].end();
142 for(std::vector<CPPL_INT>::iterator q=
line[J].begin(); q!=line_J_end; q++){
143 if(*q==C){ *q=c;
break; }
151 std::cerr <<
"# [NOTE]@dssmatrix::del(CPPL_INT&, CPPL_INT&): The required component was not listed. Your input was (" << i <<
"," << j <<
")." << std::endl;
160 {CPPL_VERBOSE_REPORT;
162 if( c<0 || c>=CPPL_INT(
data.size()) ){
164 std::cerr <<
"The required element is out of the matrix volume." << std::endl
165 <<
"Your input was (" << c <<
")." << std::endl;
170 if( c==CPPL_INT(
data.size()-1) ){
172 const std::vector<CPPL_INT>::iterator line_i_end =
line[
i].end();
173 for(std::vector<CPPL_INT>::iterator q=
line[i].begin(); q!=line_i_end; q++){
174 if(*q==c){
line[
i].erase(q);
break; }
177 const std::vector<CPPL_INT>::iterator line_j_end =
line[j].end();
178 for(std::vector<CPPL_INT>::iterator q=
line[j].begin(); q!=line_j_end; q++){
179 if(*q==c){
line[j].erase(q);
break; }
187 CPPL_INT C =CPPL_INT(
data.size()-1);
193 const std::vector<CPPL_INT>::iterator line_i_end =
line[
i].end();
194 for(std::vector<CPPL_INT>::iterator q=
line[i].begin(); q!=line_i_end; q++){
195 if(*q==c){
line[
i].erase(q);
break; }
198 const std::vector<CPPL_INT>::iterator line_j_end =
line[j].end();
199 for(std::vector<CPPL_INT>::iterator q=
line[j].begin(); q!=line_j_end; q++){
200 if(*q==c){
line[j].erase(q);
break; }
205 const std::vector<CPPL_INT>::iterator line_I_end =
line[I].end();
206 for(std::vector<CPPL_INT>::iterator q=
line[I].begin(); q!=line_I_end; q++){
207 if(*q==C){ *q=c;
break; }
210 const std::vector<CPPL_INT>::iterator line_J_end =
line[J].end();
211 for(std::vector<CPPL_INT>::iterator q=
line[J].begin(); q!=line_J_end; q++){
212 if(*q==C){ *q=c;
break; }
229 {CPPL_VERBOSE_REPORT;
230 for(CPPL_INT
i=0;
i<mat.
n;
i++){
231 for(CPPL_INT j=0; j<mat.
n; j++){
238 s <<
" " << mat.
data[c].v <<
" ";
247 s <<
"{" << mat.
data[c].v <<
"}";
263 {CPPL_VERBOSE_REPORT;
264 std::ofstream ofs(filename, std::ios::trunc);
265 ofs.setf(std::cout.flags());
266 ofs.precision(std::cout.precision());
267 ofs.width(std::cout.width());
268 ofs.fill(std::cout.fill());
270 ofs <<
"#dssmatrix " <<
n <<
" " <<
data.size() << std::endl;
272 const std::vector<dcomponent>::const_iterator data_end =
data.end();
273 for(std::vector<dcomponent>::const_iterator it=
data.begin(); it!=data_end; it++){
274 ofs << it->i <<
" " << it->j <<
" " << it->v << std::endl;
282 {CPPL_VERBOSE_REPORT;
283 std::ifstream s( filename );
286 std::cerr <<
"The file \"" << filename <<
"\" can not be opened." << std::endl;
293 if(
id !=
"dssmatrix" &&
id !=
"#dssmatrix" ){
295 std::cerr <<
"The type name of the file \"" << filename <<
"\" is not dssmatrix." << std::endl
296 <<
"Its type name was " <<
id <<
" ." << std::endl;
309 for(
size_t k=0; k<size; k++){
318 std::cerr <<
"There is something is wrong with the file \"" << filename <<
" ." << std::endl
319 <<
"Most likely, there are too many data components over the context." << std::endl;
std::vector< dcomponent > data
matrix data
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
CPPL_INT number(const CPPL_INT &, const CPPL_INT &) const
dssmatrix & resize(const CPPL_INT &, const CPPL_INT=0, const CPPL_INT=0)
dssmatrix & del(const CPPL_INT, const CPPL_INT)
dssmatrix & put(const CPPL_INT &, const CPPL_INT &, const double &)
Component Class for Real Double-precision Sparse Matrix Classes.
bool isListed(const CPPL_INT &, const CPPL_INT &) const
_dgematrix i(const _dgbmatrix &mat)
double operator()(const CPPL_INT &, const CPPL_INT &) const
std::ostream & operator<<(std::ostream &s, const dssmatrix &mat)
void write(const char *) const
Real Double-precision Symmetric Sparse Matrix Class.
CPPL_INT n
matrix column size