6 if( i<0 || j<0 ||
m<=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 " <<
m <<
"x" <<
n <<
"." << std::endl;
15 const std::vector<CPPL_INT>::const_iterator rows_i_end =
rows[
i].end();
16 for(std::vector<CPPL_INT>::const_iterator p=
rows[i].begin(); p!=rows_i_end; p++){
17 if(
data[*p].j==j){
return data[*p].v; }
21 return comple(0.0,0.0);
29 if( i<0 || j<0 ||
m<=i ||
n<=j ){
31 std::cerr <<
"The required component is out of the matrix size." << std::endl
32 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
m <<
"x" <<
n <<
"." << std::endl;
38 const std::vector<CPPL_INT>::iterator rows_i_end =
rows[
i].end();
39 for(std::vector<CPPL_INT>::iterator p=
rows[i].begin(); p!=rows_i_end; p++){
40 if(
data[*p].j==j){
return data[*p].v; }
45 cols[j].push_back(CPPL_INT(
data.size()));
59 if( i<0 || j<0 ||
m<=i ||
n<=j ){
61 std::cerr <<
"The required component is out of the matrix size." << std::endl
62 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
m <<
"x" <<
n <<
"." << std::endl;
68 std::cerr <<
"The required component is already listed." << std::endl
69 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
76 cols[j].push_back(CPPL_INT(
data.size()));
91 if( i<0 || j<0 ||
m<=i ||
n<=j ){
93 std::cerr <<
"The required component is out of the matrix size." << std::endl
94 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
m <<
"x" <<
n <<
"." << std::endl;
100 const std::vector<CPPL_INT>::iterator rows_i_end =
rows[
i].end();
101 for(std::vector<CPPL_INT>::iterator p=
rows[i].begin(); p!=rows_i_end; p++){
105 CPPL_INT C =CPPL_INT(
data.size()-1);
113 const std::vector<CPPL_INT>::iterator cols_j_end =
cols[j].end();
114 for(std::vector<CPPL_INT>::iterator q=
cols[j].begin(); q!=cols_j_end; q++){
115 if(*q==c){
cols[j].erase(q);
break; }
119 CPPL_INT I(data[c].i), J(data[c].j);
120 const std::vector<CPPL_INT>::iterator rows_I_end =
rows[I].end();
121 for(std::vector<CPPL_INT>::iterator q=
rows[I].begin(); q!=rows_I_end; q++){
122 if(*q==C){ *q=c;
break; }
124 const std::vector<CPPL_INT>::iterator cols_J_end =
cols[J].end();
125 for(std::vector<CPPL_INT>::iterator q=
cols[J].begin(); q!=cols_J_end; q++){
126 if(*q==C){ *q=c;
break; }
133 std::cerr <<
"# [NOTE] zgsmatrix::del(CPPL_INT&, CPPL_INT&): The required component was not listed. Your input was (" << i <<
"," << j <<
")." << std::endl;
142 {CPPL_VERBOSE_REPORT;
144 if( c<0 || c>=CPPL_INT(
data.size()) ){
146 std::cerr <<
"The required element is out of the matrix volume." << std::endl
147 <<
"Your input was (" << c <<
")." << std::endl;
152 if( c==CPPL_INT(
data.size()-1) ){
154 const std::vector<CPPL_INT>::iterator rows_i_end =
rows[
i].end();
155 for(std::vector<CPPL_INT>::iterator q=
rows[i].begin(); q!=rows_i_end; q++){
156 if(*q==c){
rows[
i].erase(q);
break; }
158 const std::vector<CPPL_INT>::iterator cols_j_end =
cols[j].end();
159 for(std::vector<CPPL_INT>::iterator q=
cols[j].begin(); q!=cols_j_end; q++){
160 if(*q==c){
cols[j].erase(q);
break; }
167 CPPL_INT C =CPPL_INT(
data.size()-1);
171 const std::vector<CPPL_INT>::iterator rows_i_end =
rows[
i].end();
172 for(std::vector<CPPL_INT>::iterator q=
rows[i].begin(); q!=rows_i_end; q++){
173 if(*q==c){
rows[
i].erase(q);
break; }
175 const std::vector<CPPL_INT>::iterator cols_j_end =
cols[j].end();
176 for(std::vector<CPPL_INT>::iterator q=
cols[j].begin(); q!=cols_j_end; q++){
177 if(*q==c){
cols[j].erase(q);
break; }
180 const std::vector<CPPL_INT>::iterator rows_I_end =
rows[I].end();
181 for(std::vector<CPPL_INT>::iterator q=
rows[I].begin(); q!=rows_I_end; q++){
182 if(*q==C){ *q=c;
break; }
184 const std::vector<CPPL_INT>::iterator cols_J_end =
cols[J].end();
185 for(std::vector<CPPL_INT>::iterator q=
cols[J].begin(); q!=cols_J_end; q++){
186 if(*q==C){ *q=c;
break; }
201 {CPPL_VERBOSE_REPORT;
202 for(CPPL_INT
i=0;
i<mat.
m;
i++){
203 const std::vector<CPPL_INT>::const_iterator mat_rows_i_end =mat.
rows[
i].end();
204 for(CPPL_INT j=0; j<mat.
n; j++){
205 std::vector<CPPL_INT>::const_iterator q;
206 for(q=mat.
rows[
i].begin(); q!=mat_rows_i_end; q++){
207 if(mat.
data[*q].j==j){
break; }
209 if(q!=mat_rows_i_end){ s <<
" " << mat.
data[*q].v; }
224 {CPPL_VERBOSE_REPORT;
225 std::ofstream ofs(filename, std::ios::trunc);
226 ofs.setf(std::cout.flags());
227 ofs.precision(std::cout.precision());
228 ofs.width(std::cout.width());
229 ofs.fill(std::cout.fill());
231 ofs <<
"#zgsmatrix " <<
m <<
" " <<
n <<
" " <<
data.size() << std::endl;
233 const std::vector<zcomponent>::const_iterator data_end =
data.end();
234 for(std::vector<zcomponent>::const_iterator it=
data.begin(); it!=data_end; it++){
235 ofs << it->i <<
" " << it->j <<
" " << it->v << std::endl;
243 {CPPL_VERBOSE_REPORT;
244 std::ifstream s( filename );
247 std::cerr <<
"The file \"" << filename <<
"\" can not be opened." << std::endl;
253 if(
id !=
"zgsmatrix" &&
id !=
"#zgsmatrix" ){
255 std::cerr <<
"The type name of the file \"" << filename <<
"\" is not zgsmatrix." << std::endl
256 <<
"Its type name was " <<
id <<
" ." << std::endl;
269 for(
size_t k=0; k<size; k++){
278 std::cerr <<
"There is something is wrong with the file \"" << filename <<
" ." << std::endl
279 <<
"Most likely, there are too many data components over the context." << std::endl;
Complex Double-precision General Sparse Matrix Class.
zgsmatrix & del(const CPPL_INT, const CPPL_INT)
bool isListed(const CPPL_INT &, const CPPL_INT &)
zgsmatrix & resize(const CPPL_INT &, const CPPL_INT &, const CPPL_INT=0, const CPPL_INT=0)
_dgematrix i(const _dgbmatrix &mat)
zgsmatrix & put(const CPPL_INT &, const CPPL_INT &, const comple &)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
std::vector< zcomponent > data
matrix data
Component Class for Complex Double-precision Sparse Matrix Classes.
std::ostream & operator<<(std::ostream &s, const zgsmatrix &mat)
void write(const char *) const
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
CPPL_INT m
matrix row size
CPPL_INT n
matrix column size
comple operator()(const CPPL_INT &, const CPPL_INT &) const