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){
20 if( i>j ){
return data[*p].v; }
26 return comple(0.0,0.0);
34 if( i<0 || j<0 ||
n<=i ||
n<=j ){
36 std::cerr <<
"The required component is out of the matrix size." << std::endl
37 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
n <<
"x" <<
n <<
"." << std::endl;
43 const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
45 const std::vector<CPPL_INT>::const_iterator line_ii_end =
line[ii].end();
46 for(std::vector<CPPL_INT>::const_iterator p=
line[ii].begin(); p!=line_ii_end; p++){
47 if(
data[*p].i==ii &&
data[*p].j==jj){
55 line[j].push_back(CPPL_INT(
data.size()));
60 line[j].push_back(CPPL_INT(
data.size()));
80 if( i<0 || j<0 ||
n<=i ||
n<=j ){
82 std::cerr <<
"The required component is out of the matrix size." << std::endl
83 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
n <<
"x" <<
n <<
"." << std::endl;
89 std::cerr <<
"The required component is already listed." << std::endl
90 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
101 line[
i].push_back(CPPL_INT(
data.size()));
102 line[j].push_back(CPPL_INT(
data.size()));
106 line[
i].push_back(CPPL_INT(
data.size()));
107 line[j].push_back(CPPL_INT(
data.size()));
121 {CPPL_VERBOSE_REPORT;
123 if( i<0 || j<0 ||
n<=i ||
n<=j ){
125 std::cerr <<
"The required component is out of the matrix size." << std::endl
126 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
131 const CPPL_INT ii(std::max(i,j)), jj(std::min(i,j));
134 const std::vector<CPPL_INT>::iterator line_ii_end =
line[ii].end();
135 for(std::vector<CPPL_INT>::iterator p=
line[ii].begin(); p!=line_ii_end; p++){
136 if(
data[*p].i==ii &&
data[*p].j==jj ){
139 CPPL_INT C =CPPL_INT(
data.size()-1);
148 const std::vector<CPPL_INT>::iterator line_jj_end =
line[jj].end();
149 for(std::vector<CPPL_INT>::iterator pj=
line[jj].begin(); pj!=line_jj_end; pj++){
150 if(*pj==c){
line[jj].erase(pj);
break; }
155 CPPL_INT I(data[c].i), J(data[c].j);
156 const std::vector<CPPL_INT>::iterator line_I_end =
line[I].end();
157 for(std::vector<CPPL_INT>::iterator q=
line[I].begin(); q!=line_I_end; q++){
158 if(*q==C){ *q=c;
break; }
161 const std::vector<CPPL_INT>::iterator line_J_end =
line[J].end();
162 for(std::vector<CPPL_INT>::iterator q=
line[J].begin(); q!=line_J_end; q++){
163 if(*q==C){ *q=c;
break; }
171 std::cerr <<
"# [NOTE]@zhsmatrix::del(CPPL_INT&, CPPL_INT&): The required component was not listed. Your input was (" << i <<
"," << j <<
")." << std::endl;
180 {CPPL_VERBOSE_REPORT;
182 if( c<0 || c>=CPPL_INT(
data.size()) ){
184 std::cerr <<
"The required element is out of the matrix volume." << std::endl
185 <<
"Your input was (" << c <<
")." << std::endl;
190 if( c==CPPL_INT(
data.size()-1) ){
192 const std::vector<CPPL_INT>::iterator line_i_end =
line[
i].end();
193 for(std::vector<CPPL_INT>::iterator q=
line[i].begin(); q!=line_i_end; q++){
194 if( *q==c ){
line[
i].erase(q);
break; }
197 const std::vector<CPPL_INT>::iterator line_j_end =
line[j].end();
198 for(std::vector<CPPL_INT>::iterator q=
line[j].begin(); q!=line_j_end; q++){
199 if( *q==c ){
line[j].erase(q);
break; }
207 CPPL_INT C =CPPL_INT(
data.size()-1);
212 const std::vector<CPPL_INT>::iterator line_i_end =
line[
i].end();
213 for(std::vector<CPPL_INT>::iterator q=
line[i].begin(); q!=line_i_end; q++){
214 if( *q==c ){
line[
i].erase(q);
break; }
217 const std::vector<CPPL_INT>::iterator line_j_end =
line[j].end();
218 for(std::vector<CPPL_INT>::iterator q=
line[j].begin(); q!=line_j_end; q++){
219 if( *q==c ){
line[j].erase(q);
break; }
223 const std::vector<CPPL_INT>::iterator line_I_end =
line[I].end();
224 for(std::vector<CPPL_INT>::iterator q=
line[I].begin(); q!=line_I_end; q++){
225 if(*q==C){ *q=c;
break; }
228 const std::vector<CPPL_INT>::iterator line_J_end =
line[J].end();
229 for(std::vector<CPPL_INT>::iterator q=
line[J].begin(); q!=line_J_end; q++){
230 if(*q==C){ *q=c;
break; }
246 {CPPL_VERBOSE_REPORT;
247 for(CPPL_INT
i=0;
i<mat.
n;
i++){
248 for(CPPL_INT j=0; j<=
i; j++){
254 s <<
" " << mat.
data[c].v <<
" ";
257 for(CPPL_INT j=
i+1; j<mat.
n; j++){
278 {CPPL_VERBOSE_REPORT;
279 std::ofstream ofs(filename, std::ios::trunc);
280 ofs.setf(std::cout.flags());
281 ofs.precision(std::cout.precision());
282 ofs.width(std::cout.width());
283 ofs.fill(std::cout.fill());
285 ofs <<
"#zhsmatrix " <<
n <<
" " <<
data.size() << std::endl;
287 const std::vector<zcomponent>::const_iterator data_end =
data.end();
288 for(std::vector<zcomponent>::const_iterator it=
data.begin(); it!=data_end; it++){
289 ofs << it->i <<
" " << it->j <<
" " << it->v << std::endl;
297 {CPPL_VERBOSE_REPORT;
298 std::ifstream s( filename );
301 std::cerr <<
"The file \"" << filename <<
"\" can not be opened." << std::endl;
307 if(
id !=
"zhsmatrix" &&
id !=
"#zhsmatrix" ){
309 std::cerr <<
"The type name of the file \"" << filename <<
"\" is not zhsmatrix." << std::endl
310 <<
"Its type name was " <<
id <<
" ." << std::endl;
323 for(
size_t k=0; k<size; k++){
332 std::cerr <<
"There is something is wrong with the file \"" << filename <<
" ." << std::endl
333 <<
"Most likely, there are too many data components over the context." << std::endl;
bool isListed(const CPPL_INT &, const CPPL_INT &) const
zhsmatrix & put(const CPPL_INT &, const CPPL_INT &, const comple &)
_dgematrix i(const _dgbmatrix &mat)
CPPL_INT number(const CPPL_INT &, const CPPL_INT &) const
CPPL_INT n
matrix column size
_zcovector conj(const _zcovector &vec)
std::vector< zcomponent > data
matrix data
comple operator()(const CPPL_INT &, const CPPL_INT &) const
Component Class for Complex Double-precision Sparse Matrix Classes.
std::vector< std::vector< CPPL_INT > > line
vector of vector to store the entry information of component for each row and column ...
std::ostream & operator<<(std::ostream &s, const zhsmatrix &mat)
(DO NOT USE) Complex-double Class for Hermitian matrices
Complex Double-precision Hermitian Sparse Matrix Class.
zhsmatrix & resize(const CPPL_INT &, const CPPL_INT=0, const CPPL_INT=0)
void write(const char *) const
zhsmatrix & del(const CPPL_INT, const CPPL_INT)