18 bool ownReal,
bool ownImag,
20 :
Operator(2*Op_Real->Height(), 2*Op_Real->Width())
25 , convention_(convention)
26 , x_r_(NULL, Op_Real->Width())
27 , x_i_(NULL, Op_Real->Width())
28 , y_r_(NULL, Op_Real->Height())
29 , y_i_(NULL, Op_Real->Height())
128 const int nrows_r = (A_r)?A_r->
Height():0;
129 const int nrows_i = (A_i)?A_i->
Height():0;
130 const int nrows = std::max(nrows_r, nrows_i);
132 const int *I_r = (A_r)?A_r->
GetI():NULL;
133 const int *I_i = (A_i)?A_i->
GetI():NULL;
135 const int *J_r = (A_r)?A_r->
GetJ():NULL;
136 const int *J_i = (A_i)?A_i->
GetJ():NULL;
138 const double *D_r = (A_r)?A_r->
GetData():NULL;
139 const double *D_i = (A_i)?A_i->
GetData():NULL;
141 const int nnz_r = (I_r)?I_r[nrows]:0;
142 const int nnz_i = (I_i)?I_i[nrows]:0;
143 const int nnz = 2 * (nnz_r + nnz_i);
145 int *I =
new int[this->
Height()+1];
146 int *J =
new int[nnz];
147 double *D =
new double[nnz];
152 I[nrows] = nnz_r + nnz_i;
153 for (
int i=0; i<nrows; i++)
155 I[i + 1] = ((I_r)?I_r[i+1]:0) + ((I_i)?I_i[i+1]:0);
156 I[i + nrows + 1] = I[i+1] + nnz_r + nnz_i;
160 const int off_i = (I_i)?(I_i[i+1] - I_i[i]):0;
161 for (
int j=0; j<I_r[i+1] - I_r[i]; j++)
163 J[I[i] + j] = J_r[I_r[i] + j];
164 D[I[i] + j] = D_r[I_r[i] + j];
166 J[I[i+nrows] + off_i + j] = J_r[I_r[i] + j] + nrows;
167 D[I[i+nrows] + off_i + j] = factor*D_r[I_r[i] + j];
172 const int off_r = (I_r)?(I_r[i+1] - I_r[i]):0;
173 for (
int j=0; j<I_i[i+1] - I_i[i]; j++)
175 J[I[i] + off_r + j] = J_i[I_i[i] + j] + nrows;
176 D[I[i] + off_r + j] = -D_i[I_i[i] + j];
178 J[I[i+nrows] + j] = J_i[I_i[i] + j];
179 D[I[i+nrows] + j] = factor*D_i[I_i[i] + j];
virtual ~ComplexOperator()
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
Alternate convention for damping operators.
double * GetData() const
Return a pointer to the beginning of the Vector data.
ComplexOperator(Operator *Op_Real, Operator *Op_Imag, bool ownReal, bool ownImag, Convention convention=HERMITIAN)
Constructs complex operator object.
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
double * GetData() const
Return element data, i.e. array A.
int * GetI() const
Return the array I.
SparseMatrix * GetSystemMatrix() const
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Vector & Add(const double a, const Vector &Va)
(*this) += a * Va
Native convention for Hermitian operators.
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
int * GetJ() const
Return the array J.