Actual source code: dlregis_taolinesearch.c

      1: #define TAOLINESEARCH_DLL
      2: #include <petsc/private/taolinesearchimpl.h>

      4: PETSC_EXTERN PetscErrorCode TaoLineSearchCreate_Unit(TaoLineSearch);
      5: PETSC_EXTERN PetscErrorCode TaoLineSearchCreate_MT(TaoLineSearch);
      6: PETSC_EXTERN PetscErrorCode TaoLineSearchCreate_GPCG(TaoLineSearch);
      7: PETSC_EXTERN PetscErrorCode TaoLineSearchCreate_Armijo(TaoLineSearch);
      8: PETSC_EXTERN PetscErrorCode TaoLineSearchCreate_OWArmijo(TaoLineSearch);
      9: static PetscBool            TaoLineSearchPackageInitialized = PETSC_FALSE;

     11: /*@C
     12:   TaoLineSearchFinalizePackage - This function destroys everything in the `TaoLineSearch` package. It is called from `PetscFinalize()`.

     14:   Level: developer

     16: .seealso: `Tao`, `TaoLineSearch`
     17: @*/
     18: PetscErrorCode TaoLineSearchFinalizePackage(void)
     19: {
     20:   PetscFunctionBegin;
     21:   PetscCall(PetscFunctionListDestroy(&TaoLineSearchList));
     22:   TaoLineSearchPackageInitialized = PETSC_FALSE;
     23:   PetscFunctionReturn(PETSC_SUCCESS);
     24: }

     26: /*@C
     27:   TaoLineSearchInitializePackage - This function registers the line-search
     28:   algorithms in `Tao`.  When using shared or static libraries, this function is called from the
     29:   first entry to `TaoCreate()`; when using dynamic, it is called
     30:   from PetscDLLibraryRegister_tao()

     32:   Level: developer

     34: .seealso: `Tao`, `TaoLineSearch`, `TaoLineSearchCreate()`
     35: @*/
     36: PetscErrorCode TaoLineSearchInitializePackage(void)
     37: {
     38:   PetscFunctionBegin;
     39:   if (TaoLineSearchPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
     40:   TaoLineSearchPackageInitialized = PETSC_TRUE;
     41: #if !defined(PETSC_USE_COMPLEX)
     42:   PetscCall(PetscClassIdRegister("TaoLineSearch", &TAOLINESEARCH_CLASSID));
     43:   PetscCall(PetscInfoProcessClass("taolinesearch", 1, &TAOLINESEARCH_CLASSID));
     44:   PetscCall(TaoLineSearchRegister("unit", TaoLineSearchCreate_Unit));
     45:   PetscCall(TaoLineSearchRegister("more-thuente", TaoLineSearchCreate_MT));
     46:   PetscCall(TaoLineSearchRegister("gpcg", TaoLineSearchCreate_GPCG));
     47:   PetscCall(TaoLineSearchRegister("armijo", TaoLineSearchCreate_Armijo));
     48:   PetscCall(TaoLineSearchRegister("owarmijo", TaoLineSearchCreate_OWArmijo));
     49:   PetscCall(PetscLogEventRegister("TaoLSApply", TAOLINESEARCH_CLASSID, &TAOLINESEARCH_Apply));
     50:   PetscCall(PetscLogEventRegister("TaoLSEval", TAOLINESEARCH_CLASSID, &TAOLINESEARCH_Eval));
     51: #endif
     52:   PetscCall(PetscRegisterFinalize(TaoLineSearchFinalizePackage));
     53:   PetscFunctionReturn(PETSC_SUCCESS);
     54: }