# sc_Function man page

sc::Function — The **Function** class is an abstract base class that, given a set of coordinates, will compute a value and possibly a gradient and hessian at that point.

## Synopsis

`#include <function.h>`

Inherits **sc::SavableState**, and **sc::Compute**.

Inherited by **sc::MolecularEnergy**, and **sc::Volume**.

### Public Member Functions

Function(StateIn&)Function(constFunction&)Function(constRef<KeyVal> &, double funcacc=DBL_EPSILON, double gradacc=DBL_EPSILON, double hessacc=DBL_EPSILON)The keyval constructor reads the following keywords:Function&operator=(constFunction&)Ref<SCMatrixKit>matrixkit() constReturn theSCMatrixKitused to construct vectors and matrices.RefSCDimension dimension() constReturn theSCDimensionof the problem.

virtual voidsave_data_state(StateOut&)Save the base classes (with save_data_state) and the members in the same order that theStateInCTOR initializes them.

virtual doublevalue()Return the value of the function.

intvalue_needed() constReturns nonzero if the current value is not up-to-date.

intdo_value(int)If passed a nonzero number, compute the value the next timecompute()is called.AccResultdouble&value_result()

virtual voidset_desired_value_accuracy(double)Set the accuracy to which the value is to be computed.

virtual doubleactual_value_accuracy() constReturn the accuracy with which the value has been computed.

virtual doubledesired_value_accuracy() constReturn the accuracy with which the value is to be computed.

virtual voidguess_hessian(RefSymmSCMatrix&)Computea quick, approximate hessian.

virtualRefSymmSCMatrix inverse_hessian(RefSymmSCMatrix&)

virtual intvalue_implemented() constInformation about the availability of values, gradients, and hessians.

virtual intgradient_implemented() const

virtual inthessian_implemented() const

virtual voidset_x(constRefSCVector&)Set and retrieve the coordinate values.RefSCVector get_x() const

constRefSCVector&get_x_no_copy() const

virtualRef<NonlinearTransform>change_coordinates()An optimizer can call change coordinates periodically to give the function an opportunity to change its coordinate system.

virtual voidExEnv::out0()) constPrint information about the object.

**Gradient Members**

These are analogous to the routines that deal with values, but work with gradients instead.

virtualRefSCVector gradient()

intgradient_needed() const

intdo_gradient(int)

virtual voidset_desired_gradient_accuracy(double)

virtual doubleactual_gradient_accuracy() const

virtual doubledesired_gradient_accuracy() constAccResultRefSCVector&gradient_result()

**Hessian Members**

These are analogous to the routines that deal with values, but work with the hessian instead.

virtualRefSymmSCMatrix hessian()

inthessian_needed() const

intdo_hessian(int)

virtual voidset_desired_hessian_accuracy(double)

virtual doubleactual_hessian_accuracy() const

virtual doubledesired_hessian_accuracy() constAccResultRefSymmSCMatrix&hessian_result()

### Protected Member Functions

virtual voidset_matrixkit(constRef<SCMatrixKit> &)Set theSCMatrixKitthat should be used to construct the requisite vectors and matrices.

virtual voidset_dimension(constRefSCDimension&)RefSCVector&get_x_reference()Get read/write access to the coordinates for modification.

voiddo_change_coordinates(constRef<NonlinearTransform> &)Change the coordinate system and apply the given transform to intermediates matrices and vectors.

**Update Members**

Update the various computable results.

virtual voidset_value(double)

virtual voidset_gradient(RefSCVector&)

virtual voidset_hessian(RefSymmSCMatrix&)

**Accuracy Setting Members**

Set the accuracies with which the various computables have been computed.

virtual voidset_actual_value_accuracy(double)

virtual voidset_actual_gradient_accuracy(double)

virtual voidset_actual_hessian_accuracy(double)

### Protected Attributes

Ref<SCMatrixKit>matrixkit_Used to construct new matrices.RefSCVector x_The variables.RefSCDimension dim_The dimension of x_.AccResultdouble value_The value of the function at x_.AccResultRefSCVector gradient_The gradient at x_.AccResultRefSymmSCMatrix hessian_The hessian at x_.

### Additional Inherited Members

## Detailed Description

The **Function** class is an abstract base class that, given a set of coordinates, will compute a value and possibly a gradient and hessian at that point.

## Constructor & Destructor Documentation

### sc::Function::Function (const Ref< KeyVal > &, double funcacc = DBL_EPSILON, double gradacc = DBL_EPSILON, double hessacc = DBL_EPSILON)

The keyval constructor reads the following keywords:

`matrixkit`

- Gives a
**SCMatrixKit**object. If it is not specified, a default**SCMatrixKit**is selected.

`value_accuracy`

- Sets the accuracy to which values are computed. The default is the machine accuracy.

`gradient_accuracy`

- Sets the accuracy to which gradients are computed. The default is the machine accuracy.

`hessian_accuracy`

- Sets the accuracy to which hessians are computed. The default is the machine accuracy.

## Member Function Documentation

### virtual Ref<NonlinearTransform> sc::Function::change_coordinates () [virtual]

An optimizer can call change coordinates periodically to give the function an opportunity to change its coordinate system. A return value of 0 means the coordinates were not changed. Otherwise, a transform object to the new coordinate system is return. The function object applies the transform to any objects it contains. This will obsolete the function data.

Reimplemented in **sc::MolecularEnergy**.

Referenced by get_x_reference().

### void sc::Function::do_change_coordinates (const Ref< NonlinearTransform > &) [protected]

Change the coordinate system and apply the given transform to intermediates matrices and vectors.

Referenced by get_x_reference().

### int sc::Function::do_value (int)

If passed a nonzero number, compute the value the next time **compute()** is called. Return a nonzero number if the value was previously to be computed.

Referenced by get_x_reference().

### Ref<SCMatrixKit> sc::Function::matrixkit () const

Return the **SCMatrixKit** used to construct vectors and matrices.

Referenced by get_x_reference().

### virtual void sc::Function::save_data_state (StateOut &) [virtual]

Save the base classes (with save_data_state) and the members in the same order that the **StateIn** CTOR initializes them. This must be implemented by the derived class if the class has data.

Reimplemented from **sc::SavableState**.

Reimplemented in **sc::MBPT2**, **sc::MBPT2_R12**, **sc::SumMolecularEnergy**, **sc::HCoreWfn**, **sc::SCF**, **sc::PsiCCSD_T**, **sc::PsiCCSD**, **sc::Wavefunction**, **sc::MolecularEnergy**, **sc::HSOSSCF**, **sc::PsiSCF**, **sc::HSOSKS**, **sc::OneBodyWavefunction**, **sc::UKS**, **sc::CLSCF**, **sc::CLKS**, **sc::UnrestrictedSCF**, **sc::TaylorMolecularEnergy**, **sc::TCSCF**, **sc::ExtendedHuckelWfn**, **sc::OSSSCF**, **sc::PsiWavefunction**, **sc::UHF**, **sc::CLHF**, **sc::HSOSHF**, **sc::MP2BasisExtrap**, **sc::OSSHF**, and **sc::TCHF**.

Referenced by get_x_reference().

### virtual void sc::Function::set_matrixkit (const Ref< SCMatrixKit > &) [protected], [virtual]

Set the **SCMatrixKit** that should be used to construct the requisite vectors and matrices.

### virtual int sc::Function::value_implemented () const [virtual]

Information about the availability of values, gradients, and hessians.

Reimplemented in **sc::MBPT2**, **sc::MBPT2_R12**, **sc::HCoreWfn**, **sc::SumMolecularEnergy**, **sc::HSOSKS**, **sc::UKS**, **sc::CLKS**, **sc::ExtendedHuckelWfn**, **sc::TaylorMolecularEnergy**, **sc::Shape**, **sc::UHF**, **sc::CLHF**, **sc::HSOSHF**, **sc::OSSHF**, and **sc::TCHF**.

Referenced by get_x_reference().

## Author

Generated automatically by Doxygen for MPQC from the source code.