| Line 9... |
Line 9... |
Vec w2;
|
Vec w2;
|
} ST_CAYLEY;
|
} ST_CAYLEY;
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STApply_Cayley"
|
#define __FUNCT__ "STApply_Cayley"
|
static int STApply_Cayley(ST st,Vec x,Vec y)
|
PetscErrorCode STApply_Cayley(ST st,Vec x,Vec y)
|
{
|
{
|
int ierr;
|
PetscErrorCode ierr;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
PetscScalar tau = ctx->tau;
|
PetscScalar tau = ctx->tau;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
if (st->shift_matrix == STMATMODE_INPLACE) { tau = tau + st->sigma; };
|
if (st->shift_matrix == STMATMODE_INPLACE) { tau = tau + st->sigma; };
|
|
|
if (st->B) {
|
if (st->B) {
|
| Line 36... |
Line 36... |
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STApplyNoB_Cayley"
|
#define __FUNCT__ "STApplyNoB_Cayley"
|
static int STApplyNoB_Cayley(ST st,Vec x,Vec y)
|
PetscErrorCode STApplyNoB_Cayley(ST st,Vec x,Vec y)
|
{
|
{
|
int ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
ierr = STAssociatedKSPSolve(st,x,y);CHKERRQ(ierr);
|
ierr = STAssociatedKSPSolve(st,x,y);CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STApplyB_Cayley"
|
#define __FUNCT__ "STApplyB_Cayley"
|
static int STApplyB_Cayley(ST st,Vec x,Vec y)
|
PetscErrorCode STApplyB_Cayley(ST st,Vec x,Vec y)
|
{
|
{
|
int ierr;
|
PetscErrorCode ierr;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
PetscScalar tau = ctx->tau;
|
PetscScalar tau = ctx->tau;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
if (st->shift_matrix == STMATMODE_INPLACE) { tau = tau + st->sigma; };
|
if (st->shift_matrix == STMATMODE_INPLACE) { tau = tau + st->sigma; };
|
|
|
if (st->B) {
|
if (st->B) {
|
| Line 72... |
Line 72... |
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STBackTransform_Cayley"
|
#define __FUNCT__ "STBackTransform_Cayley"
|
int STBackTransform_Cayley(ST st,PetscScalar *eigr,PetscScalar *eigi)
|
PetscErrorCode STBackTransform_Cayley(ST st,PetscScalar *eigr,PetscScalar *eigi)
|
{
|
{
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
#ifndef PETSC_USE_COMPLEX
|
#ifndef PETSC_USE_COMPLEX
|
PetscScalar t,i,r;
|
PetscScalar t,i,r;
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
| Line 100... |
Line 100... |
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STPost_Cayley"
|
#define __FUNCT__ "STPost_Cayley"
|
int STPost_Cayley(ST st)
|
PetscErrorCode STPost_Cayley(ST st)
|
{
|
{
|
PetscScalar alpha;
|
PetscErrorCode ierr;
|
int ierr;
|
PetscScalar alpha;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
if (st->shift_matrix == STMATMODE_INPLACE) {
|
if (st->shift_matrix == STMATMODE_INPLACE) {
|
alpha = st->sigma;
|
alpha = st->sigma;
|
if( st->B ) { ierr = MatAXPY(&alpha,st->B,st->A,st->str);CHKERRQ(ierr); }
|
if( st->B ) { ierr = MatAXPY(&alpha,st->B,st->A,st->str);CHKERRQ(ierr); }
|
| Line 117... |
Line 117... |
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STSetUp_Cayley"
|
#define __FUNCT__ "STSetUp_Cayley"
|
static int STSetUp_Cayley(ST st)
|
PetscErrorCode STSetUp_Cayley(ST st)
|
{
|
{
|
int ierr;
|
PetscErrorCode ierr;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
PetscScalar alpha;
|
PetscScalar alpha;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
|
|
if (st->mat) { ierr = MatDestroy(st->mat);CHKERRQ(ierr); }
|
if (st->mat) { ierr = MatDestroy(st->mat);CHKERRQ(ierr); }
|
if (!ctx->tau_set) { ctx->tau = st->sigma; }
|
if (!ctx->tau_set) { ctx->tau = st->sigma; }
|
| Line 174... |
Line 174... |
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STSetShift_Cayley"
|
#define __FUNCT__ "STSetShift_Cayley"
|
static int STSetShift_Cayley(ST st,PetscScalar newshift)
|
PetscErrorCode STSetShift_Cayley(ST st,PetscScalar newshift)
|
{
|
{
|
int ierr;
|
PetscErrorCode ierr;
|
PetscScalar alpha;
|
PetscScalar alpha;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
|
|
/* Nothing to be done if STSetUp has not been called yet */
|
/* Nothing to be done if STSetUp has not been called yet */
|
if (!st->setupcalled) PetscFunctionReturn(0);
|
if (!st->setupcalled) PetscFunctionReturn(0);
|
| Line 223... |
Line 223... |
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STSetFromOptions_Cayley"
|
#define __FUNCT__ "STSetFromOptions_Cayley"
|
static int STSetFromOptions_Cayley(ST st) {
|
PetscErrorCode STSetFromOptions_Cayley(ST st)
|
int ierr;
|
{
|
PetscScalar tau;
|
PetscErrorCode ierr;
|
PetscTruth flg;
|
PetscScalar tau;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
PetscTruth flg;
|
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
ierr = PetscOptionsHead("ST Cayley Options");CHKERRQ(ierr);
|
ierr = PetscOptionsHead("ST Cayley Options");CHKERRQ(ierr);
|
ierr = PetscOptionsScalar("-st_antishift","Value of the antishift","STSetAntishift",ctx->tau,&tau,&flg); CHKERRQ(ierr);
|
ierr = PetscOptionsScalar("-st_antishift","Value of the antishift","STSetAntishift",ctx->tau,&tau,&flg); CHKERRQ(ierr);
|
if (flg) {
|
if (flg) {
|
| Line 242... |
Line 243... |
}
|
}
|
|
|
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STCayleySetAntishift_Cayley"
|
#define __FUNCT__ "STCayleySetAntishift_Cayley"
|
int STCayleySetAntishift_Cayley(ST st,PetscScalar newshift)
|
PetscErrorCode STCayleySetAntishift_Cayley(ST st,PetscScalar newshift)
|
{
|
{
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
ctx->tau = newshift;
|
ctx->tau = newshift;
|
| Line 255... |
Line 256... |
}
|
}
|
EXTERN_C_END
|
EXTERN_C_END
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STCayleySetAntishift"
|
#define __FUNCT__ "STCayleySetAntishift"
|
int STCayleySetAntishift(ST st,PetscScalar newshift)
|
PetscErrorCode STCayleySetAntishift(ST st,PetscScalar newshift)
|
{
|
{
|
int ierr, (*f)(ST,PetscScalar);
|
PetscErrorCode ierr, (*f)(ST,PetscScalar);
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
ierr = PetscObjectQueryFunction((PetscObject)st,"STCayleySetAntishift_C",(void (**)(void))&f);CHKERRQ(ierr);
|
ierr = PetscObjectQueryFunction((PetscObject)st,"STCayleySetAntishift_C",(void (**)(void))&f);CHKERRQ(ierr);
|
if (f) {
|
if (f) {
|
| Line 270... |
Line 271... |
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STView_Cayley"
|
#define __FUNCT__ "STView_Cayley"
|
static int STView_Cayley(ST st,PetscViewer viewer)
|
PetscErrorCode STView_Cayley(ST st,PetscViewer viewer)
|
{
|
{
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
PetscErrorCode ierr;
|
int ierr;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
#if !defined(PETSC_USE_COMPLEX)
|
#if !defined(PETSC_USE_COMPLEX)
|
ierr = PetscViewerASCIIPrintf(viewer," antishift: %g\n",ctx->tau);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer," antishift: %g\n",ctx->tau);CHKERRQ(ierr);
|
#else
|
#else
|
| Line 287... |
Line 288... |
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STDestroy_Cayley"
|
#define __FUNCT__ "STDestroy_Cayley"
|
static int STDestroy_Cayley(ST st)
|
PetscErrorCode STDestroy_Cayley(ST st)
|
{
|
{
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
PetscErrorCode ierr;
|
int ierr;
|
ST_CAYLEY *ctx = (ST_CAYLEY *) st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
if (ctx->w2) { ierr = VecDestroy(ctx->w2);CHKERRQ(ierr); }
|
if (ctx->w2) { ierr = VecDestroy(ctx->w2);CHKERRQ(ierr); }
|
ierr = PetscFree(ctx);CHKERRQ(ierr);
|
ierr = PetscFree(ctx);CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STCreate_Cayley"
|
#define __FUNCT__ "STCreate_Cayley"
|
int STCreate_Cayley(ST st)
|
PetscErrorCode STCreate_Cayley(ST st)
|
{
|
{
|
int ierr;
|
PetscErrorCode ierr;
|
ST_CAYLEY *ctx;
|
ST_CAYLEY *ctx;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
ierr = PetscNew(ST_CAYLEY,&ctx); CHKERRQ(ierr);
|
ierr = PetscNew(ST_CAYLEY,&ctx); CHKERRQ(ierr);
|
PetscMemzero(ctx,sizeof(ST_CAYLEY));
|
PetscMemzero(ctx,sizeof(ST_CAYLEY));
|
PetscLogObjectMemory(st,sizeof(ST_CAYLEY));
|
PetscLogObjectMemory(st,sizeof(ST_CAYLEY));
|