realpart() for sparsemat

This commit is contained in:
Jiri Pittner 2022-08-11 15:52:58 +02:00
parent 11e0429ed5
commit dc0b823c3a

View File

@ -1317,6 +1317,29 @@ for(int i=0; i<w.size(); ++i)
} }
} }
template<>
const SparseMat<double> realpart<SparseMat< std::complex<double> > >(const SparseMat< std::complex<double> > &a)
{
SparseMat<double> result(a.nrows(), a.ncols());
for(SparseMat< std::complex<double> >::iterator p=a.begin(); p!=a.end(); ++p)
{
result.add(p->row,p->col,p->elem.real());
}
if(a.issymmetric()) result.setsymmetric();
return result;
}
template<>
const SparseMat<double> imagpart<SparseMat< std::complex<double> > >(const SparseMat< std::complex<double> > &a)
{
SparseMat<double> result(a.nrows(), a.ncols());
for(SparseMat< std::complex<double> >::iterator p=a.begin(); p!=a.end(); ++p)
{
result.add(p->row,p->col,p->elem.imag());
}
if(a.issymmetric()) result.setsymmetric();
return result;
}
template<> template<>
const NRMat<double> realpart<NRMat< std::complex<double> > >(const NRMat< std::complex<double> > &a) const NRMat<double> realpart<NRMat< std::complex<double> > >(const NRMat< std::complex<double> > &a)