Prev Next Index-> contents reference index search external Up-> f2cad library dscal f2cad-> license Install get_started prototype library run.cpp utility add2lib.sh whats_new library-> d9knus d9lgmc daxpy dbesks dbskes dcsevl ddot dgamlm dgamma dgefa dgesl dint dscal idamax initds xerror dscal-> dscal.f Headings-> Prototype Fortran Source Description

dscal

Prototype
int f2cad::dscal_(integer *n, doublereal *da, doublereal *dx, integer *incx);

Fortran Source
dscal.f

Description
This example uses the routine dscal.f to compute   $\left( \begin{array}{c} f_0 \\ f_1 \end{array} \right) = a \left( \begin{array}{c} 1 \\ 2 \end{array} \right)$  Using the f2cad_link routines f2cad::Independent and f2cad::Dependent, this defines the function   $f(a) = \left( \begin{array}{c} a \\ 2 a \end{array} \right)$  We check that the derivative of this function, calculated using the f2cad::Partial routine, satisfies   $f^{(1)} (a) = \left( \begin{array}{c} 1 \\ 2 \end{array} \right)$   # include <f2cad/dscal.hpp> test_result dscal(void) { bool ok = true; // Input values for dscal integer n = 1; doublereal a[1]; a[0] = 5.; // declare independent variables f2cad::Independent(n, a); integer m = 2; doublereal f[2]; f[0] = 1.; f[1] = 2.; integer incf = 1; // set f = a * f f2cad::dscal_(&n, a, f, &incf ); // declare dependent variables f2cad::Dependent(m, f); double p; p = f2cad::Partial<doublereal>(0, 0); ok &= f2cad::near_equal(p, 1., 1e-10, 1e-10); p = f2cad::Partial<doublereal>(1, 0); ok &= f2cad::near_equal(p, 2., 1e-10, 1e-10); if( ok ) return test_pass; return test_fail; } 
Input File: example/dscal.cpp