Prev Next mat_sum_sq.hpp Headings

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@This is cppad-20221105 documentation. Here is a link to its current documentation .
Source: mat_sum_sq
# ifndef CPPAD_MAT_SUM_SQ_HPP
# define CPPAD_MAT_SUM_SQ_HPP
# include <cstddef>
//
namespace CppAD {
    template <class Vector>
    void mat_sum_sq(size_t n, Vector& x , Vector& y , Vector& z)
    {   size_t i, j, k;
        // Very simple computation of y = x * x for speed comparison
        for(i = 0; i < n; i++)
        {   for(j = 0; j < n; j++)
            {   y[i * n + j] = 0.;
                for(k = 0; k < n; k++)
                    y[i * n + j] += x[i * n + k] * x[k * n + j];
            }
        }
        z[0] = 0.;
        for(i = 0; i < n; i++)
        {   for(j = 0; j < n; j++)
                z[0] += y[i * n + j];
        }
        return;
    }

}
# endif

Input File: omh/mat_sum_sq_hpp.omh