1 #ifndef QNANO_NEW_TAO_MINIMIZER_DEFINED_H 2 #define QNANO_NEW_TAO_MINIMIZER_DEFINED_H 5 #include "tools/Parameter_Pointer_Function.h" 6 #include "slepc/SLEPc_Register_Parameter_Map.h" 13 static PetscErrorCode Objective_Function(Tao tao,Vec v,PetscReal* result,
void* param){
18 ierr=VecGetArrayRead(v,(
const PetscScalar **)&cptr); CHKERRQ(ierr);
19 *result=(PetscReal) fct->f(cptr);
20 ierr=VecRestoreArrayRead(v,(
const PetscScalar **) &cptr); CHKERRQ(ierr);
27 ierr=VecCreate(PETSC_COMM_WORLD,&initialvec);CHKERRQ(ierr);
28 ierr=VecSetSizes(initialvec,PETSC_DECIDE,ppf.
get_DIM());CHKERRQ(ierr);
29 ierr=VecSetFromOptions(initialvec);CHKERRQ(ierr);
32 ierr=VecGetArray(initialvec,(PetscScalar **)&ptr);CHKERRQ(ierr);
35 ierr=VecRestoreArray(initialvec,(PetscScalar **)&ptr);CHKERRQ(ierr);
36 ierr=TaoSetInitialVector(tao,initialvec);CHKERRQ(ierr);
37 ierr=VecDestroy(&initialvec);CHKERRQ(ierr);
41 Set_Initial_Vector(ppf);
42 TaoSetObjectiveRoutine(tao, Tao_Minimizer::Objective_Function, (
void*)&ppf);
47 param_map=¶m_map_;
48 PetscInitialize(param_map->p_args,param_map->p_argv,(
char*)0,0);
49 TaoCreate(PETSC_COMM_WORLD,&tao);
50 TaoSetType(tao, TAONM);
51 TaoSetFromOptions(tao);
52 PetscViewer monviewer;
53 PetscViewerASCIIOpen(PETSC_COMM_WORLD,
"stdout",&monviewer);
54 TaoSetMonitor(tao,TaoMonitorDefault,monviewer,(PetscErrorCode (*)(
void**))PetscViewerDestroy);
59 SLEPc_Register_Parameter_Map(*param_map);
Definition: Tao_Minimizer.h:8
Definition: Parameter_Map.h:12
virtual void get_params(double *d_start) const
copy Parameters int the specified double vector
Definition: Parameter_Pointer_Function.h:19
Definition: Parameter_Pointer_Function.h:7
virtual size_t get_DIM() const
get dimension
Definition: Parameter_Pointer_Function.h:12