From 69fdfca99519ead600f2b337c83acc0cf2ce90b2 Mon Sep 17 00:00:00 2001 From: Rishabh Bali Date: Thu, 30 Nov 2023 02:49:00 +0530 Subject: [PATCH] Minor changes --- docs/userDocs/source/user/tutorials.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/userDocs/source/user/tutorials.rst b/docs/userDocs/source/user/tutorials.rst index df427c1c1..efaceb20a 100644 --- a/docs/userDocs/source/user/tutorials.rst +++ b/docs/userDocs/source/user/tutorials.rst @@ -4,7 +4,7 @@ Tutorials Clad is an open source clang plugin which supports automatic differentiation of mathematical functions in C++. Currently Clad supports four modes for automatic differentiation namely forward, reverse, Hessian, Jacobian. -Lets have a look at the forward mode +**Forward mode** .. code-block:: cpp @@ -29,7 +29,7 @@ returns a scaler value `x*x`. **Note : Currently it is necessary to define the function before `main()`.** `.dump()` method is used to get a dump of generated derivative function to the standard output. -Reverse Mode +**Reverse Mode** Clad also supports reverse mode automatic differentiation, through the `clad::gradient` API call. @@ -55,13 +55,14 @@ argument i.e. either `x` or `y` as `clad::gradient(f, "x")` not writing any argu differentiation of the function w.r.t to each input. -The Hessian Mode +**The Hessian Mode** Clad can also produce an hessian matrix through the `clad::hessian` API call. This API call is more or less similar to the reverse mode API call and differs in case of an array type input argument. .. code-block:: cpp + #include "clad/Differentiator/Differentiator.h" #include @@ -89,12 +90,13 @@ if we want to differentiate w.r.t to the first two elements of the array along w write `clad::hessian(f_arr, z[0:1])`. -The Jacobian Mode +**The Jacobian Mode** Clad can produce Jacobian of a function using its reverse mode. It returns the jacobian matrix as a flaattened vector with elements arranged in row-major format. .. code-block:: cpp + #include "clad/Differentiator/Differentiator.h" #include @@ -110,14 +112,14 @@ elements arranged in row-major format. double jac[9] = {0}; double output[3] = {0}; f_jac.execute(3, 4, 5, output, jac); - std::cout << jac[0] << " " << jac[1] << std::endl + std::cout << jac[0] << " " << jac[1] << std::endl << jac[2] << " " << jac[3] << std::endl << jac[4] << " " << jac[5] << std::endl << jac[6] << " " << jac[7] << std::endl << jac[8]<