Date: 2026-06-01T23:13:17+00:00

Actual source code: regressorimpl.h

      1: #pragma once

      3: #include <petscregressor.h>
      4: #include <petsc/private/petscimpl.h>

      6: PETSC_EXTERN PetscBool      PetscRegressorRegisterAllCalled;
      7: PETSC_EXTERN PetscErrorCode PetscRegressorRegisterAll(void);

      9: typedef struct _PetscRegressorOps *PetscRegressorOps;

     11: struct _PetscRegressorOps {
     12:   PetscErrorCode (*setup)(PetscRegressor);
     13:   PetscErrorCode (*setfromoptions)(PetscRegressor, PetscOptionItems); /* sets options from database */
     14:   PetscErrorCode (*settraining)(PetscRegressor, Mat, Vec);            /* set the training data matrix and targets */
     15:   PetscErrorCode (*fit)(PetscRegressor);                              /* compute the transformation to be applied */
     16:   PetscErrorCode (*predict)(PetscRegressor, Mat, Vec);                /* predict using fitted model */
     17:   PetscErrorCode (*destroy)(PetscRegressor);
     18:   PetscErrorCode (*reset)(PetscRegressor);
     19:   PetscErrorCode (*view)(PetscRegressor, PetscViewer);
     20: };

     22: /* Define the PetscRegressor data structure. */
     23: struct _p_PetscRegressor {
     24:   PETSCHEADER(struct _PetscRegressorOps);

     26:   PetscBool setupcalled; /* True if setup has been called */
     27:   PetscBool fitcalled;   /* True if the Fit() method has been called. */
     28:   void     *data;        /* Implementation-specific data */
     29:   Mat       training;    /* Matrix holding the training data set */
     30:   Vec       target;      /* Targets for training data (response variables or labels) */
     31:   Tao       tao;         /* Tao optimizer used by many regressor implementations */
     32:   PetscObjectParameterDeclare(PetscReal, regularizer_weight);
     33: };

     35: PETSC_EXTERN PetscLogEvent PetscRegressor_SetUp;
     36: PETSC_EXTERN PetscLogEvent PetscRegressor_Fit;
     37: PETSC_EXTERN PetscLogEvent PetscRegressor_Predict;