17 for(CPPL_INT
i=0;
i<
m;
i++){
rows[
i].resize(0); }
18 for(CPPL_INT j=0; j<
n; j++){
cols[j].resize(0); }
29 std::cerr <<
"Only square matrix can be a identity matrix." << std::endl
30 <<
"The matrix size was " <<
m <<
"x" <<
n <<
"." << std::endl;
36 for(CPPL_INT
i=0;
i<
m;
i++){
46 const std::vector<dcomponent>::iterator data_end =
data.end();
47 for(std::vector<dcomponent>::iterator it=
data.begin(); it!=data_end; it++){
86 if( _m<0 || _n<0 || _c<0 ){
88 std::cerr <<
"Matrix sizes and the length of arrays must be positive integers. " << std::endl
89 <<
"Your input was (" << _m <<
"," << _n <<
"," << _c <<
"," << _l <<
")." << std::endl;
99 for(CPPL_INT
i=0;
i<
m;
i++){
104 for(CPPL_INT
i=0;
i<
n;
i++){
115 {CPPL_VERBOSE_REPORT;
117 if(
m+dm<0 ||
n+dn<0 ){
119 std::cerr <<
"The new matrix size must be larger than zero. " << std::endl
120 <<
"Your input was (" << dm <<
", " << dn <<
")." << std::endl;
126 if(dm==0 && dn==0){
return; }
135 const std::vector<dcomponent>::reverse_iterator data_rend =
data.rend();
136 for(std::vector<dcomponent>::reverse_iterator it=
data.rbegin(); it!=data_rend; it++){
137 if( it->i>=
m ){
del( CPPL_INT(data_rend-it-1) ); }
140 for(CPPL_INT
i=0;
i<-dm;
i++){
146 for(CPPL_INT
i=0;
i<dm;
i++){
147 rows.push_back( std::vector<CPPL_INT>(0) );
154 const std::vector<dcomponent>::reverse_iterator data_rend =
data.rend();
155 for(std::vector<dcomponent>::reverse_iterator it=
data.rbegin(); it!=data_rend; it++){
156 if( it->j>=
n ){
del( CPPL_INT(data_rend-it-1) ); }
158 for(CPPL_INT j=0; j<-dn; j++){
164 for(CPPL_INT j=0; j<dn; j++){
165 cols.push_back( std::vector<CPPL_INT>(0) );
173 {CPPL_VERBOSE_REPORT;
175 if( i<0 || j<0 ||
m<=i ||
n<=j ){
177 std::cerr <<
"The required component is out of the matrix size." << std::endl
178 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
m <<
"x" <<
n <<
"." << std::endl;
182 const std::vector<CPPL_INT>::const_iterator rows_i_end =
rows[
i].end();
183 for(std::vector<CPPL_INT>::const_iterator p=
rows[i].begin(); p!=rows_i_end; p++){
184 if(
data[*p].j==j){
return 1; }
194 {CPPL_VERBOSE_REPORT;
196 if( i<0 || j<0 ||
m<=i ||
n<=j ){
198 std::cerr <<
"The required component is out of the matrix size." << std::endl
199 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " <<
m <<
"x" <<
n <<
"." << std::endl;
203 const std::vector<CPPL_INT>::iterator rows_i_end =
rows[
i].end();
204 for(std::vector<CPPL_INT>::iterator p=
rows[i].begin(); p!=rows_i_end; p++){
205 if(
data[*p].j==j){
return *p; }
218 {CPPL_VERBOSE_REPORT;
222 std::cerr <<
"Input row number must be between 0 and " << m <<
"." << std::endl
223 <<
"Your input was " << _m <<
"." << std::endl;
231 const std::vector<CPPL_INT>::const_iterator rows__m_end =
rows[_m].end();
232 for(std::vector<CPPL_INT>::const_iterator p=
rows[_m].begin(); p!=rows__m_end; p++){
242 {CPPL_VERBOSE_REPORT;
246 std::cerr <<
"Input row number must be between 0 and " << n <<
"." << std::endl
247 <<
"Your input was " << _n <<
"." << std::endl;
255 const std::vector<CPPL_INT>::const_iterator cols__n_end =
cols[_n].end();
256 for(std::vector<CPPL_INT>::const_iterator p=
cols[_n].begin(); p!=cols__n_end; p++){
266 {CPPL_VERBOSE_REPORT;
267 const std::vector<dcomponent>::reverse_iterator data_rend =
data.rend();
268 for(std::vector<dcomponent>::reverse_iterator it=
data.rbegin(); it!=data_rend; it++){
269 if( fabs(it->v)<eps ){
del( CPPL_INT(data_rend-it-1) ); }
280 {CPPL_VERBOSE_REPORT;
282 const std::vector<dcomponent>::const_iterator data_end =
data.end();
283 for(std::vector<dcomponent>::const_iterator it=
data.begin(); it!=data_end; it++){
284 std::cerr <<
"array[" << it-
data.begin() <<
"] = (" << it->i <<
"," << it->j <<
") = " << it->v << std::endl;
286 std::cerr << std::endl;
288 for(CPPL_INT
i=0;
i<
m;
i++){
289 std::cerr <<
"rows[" <<
i <<
"] =" << std::flush;
290 const size_t rows_i_size =
rows[
i].size();
291 for(
size_t k=0; k<rows_i_size; k++){
292 std::cerr <<
" " <<
rows[
i][k] << std::flush;
294 std::cerr << std::endl;
296 std::cerr << std::endl;
298 for(CPPL_INT j=0; j<
n; j++){
299 std::cerr <<
"cols[" << j <<
"] =" << std::flush;
300 const size_t cols_j_size =
cols[j].size();
301 for(
size_t k=0; k<cols_j_size; k++){
302 std::cerr <<
" " <<
cols[j][k] << std::flush;
304 std::cerr << std::endl;
308 for(std::vector<dcomponent>::const_iterator it=
data.begin(); it!=data_end; it++){
312 std::cerr <<
"The indx of the " << it-
data.begin() <<
"th element is out of the matrix size." << std::endl
313 <<
"Its i index was " << it->i <<
"." << std::endl;
320 std::cerr <<
"The indx of the " << it-
data.begin() <<
"th element is out of the matrix size." << std::endl
321 <<
"Its j index was " << it->j <<
"." << std::endl;
326 for(std::vector<dcomponent>::const_iterator IT=it+1; IT!=data_end; IT++){
327 if( it->i==IT->i && it->j==IT->j ){
329 std::cerr <<
"The (" << it->i <<
", " << it->j <<
") component is double-listed at the " << it-
data.begin() <<
"th and the" << IT-
data.begin() <<
"the elements."<< std::endl;
339 std::cerr <<
"# [NOTE]@dgsmatrix::checkup(): This sparse matrix is fine." << std::endl;
349 {CPPL_VERBOSE_REPORT;
360 {CPPL_VERBOSE_REPORT;
_dgsmatrix _(dgsmatrix &mat)
void swap(dgsmatrix &A, dgsmatrix &B)
Real Double-precision General Sparse Matrix Class.
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
void copy(const dgsmatrix &)
std::vector< dcomponent > data
matrix data
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
CPPL_INT n
matrix column size
void diet(const double=DBL_MIN)
CPPL_INT n
matrix column size
_drovector row(const CPPL_INT &) const
friend _dgsmatrix _(dgsmatrix &)
std::vector< std::vector< CPPL_INT > > cols
array of vector to store the entry information of component for each column
_dgematrix i(const _dgbmatrix &mat)
(DO NOT USE) Smart-temporary Real Double-precision General Sparse Matrix Class
Real Double-precision Row Vector Class.
bool isListed(const CPPL_INT &, const CPPL_INT &) const
CPPL_INT m
matrix row size
(DO NOT USE) Smart-temporary Real Double-precision Row Vector Class
void stretch(const CPPL_INT &, const CPPL_INT &)
dgsmatrix & del(const CPPL_INT, const CPPL_INT)
std::vector< dcomponent > data
matrix data
Real Double-precision Column Vector Class.
dgsmatrix & put(const CPPL_INT &, const CPPL_INT &, const double &)
(DO NOT USE) Smart-temporary Real Double-precision Column Vector Class
dgsmatrix & resize(const CPPL_INT &, const CPPL_INT &, const CPPL_INT=0, const CPPL_INT=0)
std::vector< std::vector< CPPL_INT > > rows
array of vector to store the entry information of component for each row
_dcovector col(const CPPL_INT &) const
void shallow_copy(const _dgsmatrix &)
CPPL_INT m
matrix row size
CPPL_INT number(const CPPL_INT &, const CPPL_INT &)