# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-23 Bradley M. Bell
# ----------------------------------------------------------------------------
{xrst_begin forward_zero}
{xrst_spell
   cout
   ostream
}

Zero Order Forward Mode: Function Values
########################################

Syntax
******

   *y0* = *f* . ``Forward`` (0, *x0* )

*y0* = *f* . ``Forward`` (0, *x0* , *s* )

Purpose
*******
We use :math:`F : \B{R}^n \rightarrow \B{R}^m` to denote the
:ref:`glossary@AD Function` corresponding to *f* .
The result of the syntax above is

.. math::

   y0 = F(x0)

See the :ref:`FunCheck discussion<FunCheck@Discussion>` for
possible differences between :math:`F(x)` and the algorithm that defined
the operation sequence.

f
*
The object *f* has prototype

   ``ADFun`` < *Base* > *f*

Note that the :ref:`ADFun-name` object *f* is not ``const`` .
After this call to ``Forward`` , the value returned by

   *f* . ``size_order`` ()

will be equal to one (see :ref:`size_order-name` ).

x0
**
The argument *x0* has prototype

   ``const`` *Vector* & *x0*

(see :ref:`forward_zero@Vector` below)
and its size must be equal to *n* , the dimension of the
:ref:`fun_property@Domain` space for *f* .

s
*
If the argument *s* is not present, ``std::cout``
is used in its place.
Otherwise, this argument has prototype

   ``std::ostream&`` *s*

It specifies where the output corresponding to :ref:`PrintFor-name` ,
and this zero order forward mode call, will be written.

y0
**
The result *y0* has prototype

   *Vector* *y0*

(see :ref:`forward_zero@Vector` below)
and its value is :math:`F(x)` at *x* = *x0* .
The size of *y0* is equal to *m* , the dimension of the
:ref:`fun_property@Range` space for *f* .

Vector
******
The type *Vector* must be a :ref:`SimpleVector-name` class with
:ref:`elements of type<SimpleVector@Elements of Specified Type>`
*Base* .
The routine :ref:`CheckSimpleVector-name` will generate an error message
if this is not the case.

Example
*******
The file
:ref:`forward.cpp-name`
contains an example and test of this operation.

Special Case
************
This is special case of :ref:`forward_order-name` where

.. math::
   :nowrap:

   \begin{eqnarray}
   Y(t) & = & F[ X(t) ]
   \\
   X(t) & = & x^{(0)} t^0 + x^{(1)} * t^1 + \cdots, + x^{(q)} * t^q + o( t^q )
   \\
   Y(t) & = & y^{(0)} t^0 + y^{(1)} * t^1 + \cdots, + y^{(q)} * t^q + o( t^q )
   \end{eqnarray}

and :math:`o( t^q ) * t^{-q} \rightarrow 0` as :math:`t \rightarrow 0`.
For this special case, :math:`q = 0`,
:math:`x^{(0)}` = *x0* ,
:math:`X(t) = x^{(0)}`, and

.. math::

   y^{(0)} = Y(t) = F[ X(t) ] = F( x^{(0)} )

which agrees with the specifications for
*y0* in the :ref:`forward_zero@Purpose` above.

{xrst_end forward_zero}
