Stan Math Library  2.20.0
reverse mode automatic differentiation
Public Member Functions | Public Attributes | List of all members
stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb > Class Template Reference

This is a subclass of the vari class for matrix multiplication A * B where A is an N by M matrix of double and B is M by K. More...

#include <multiply.hpp>

Inheritance diagram for stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >:
stan::math::vari

Public Member Functions

 multiply_mat_vari (const Eigen::Matrix< double, Ra, Ca > &A, const Eigen::Matrix< Tb, Ca, Cb > &B)
 Constructor for multiply_mat_vari. More...
 
virtual void chain ()
 Apply the chain rule to this variable based on the variables on which it depends. More...
 
- Public Member Functions inherited from stan::math::vari
 vari (double x)
 Construct a variable implementation from a value. More...
 
 vari (double x, bool stacked)
 
virtual ~vari ()
 Throw an illegal argument exception. More...
 
void init_dependent ()
 Initialize the adjoint for this (dependent) variable to 1. More...
 
void set_zero_adjoint ()
 Set the adjoint value of this variable to 0. More...
 

Public Attributes

int A_rows_
 
int A_cols_
 
int B_cols_
 
int A_size_
 
int B_size_
 
double * Ad_
 
double * Bd_
 
vari ** variRefB_
 
vari ** variRefAB_
 
- Public Attributes inherited from stan::math::vari
const double val_
 The value of this variable. More...
 
double adj_
 The adjoint of this variable, which is the partial derivative of this variable with respect to the root variable. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from stan::math::vari
static void * operator new (size_t nbytes)
 Allocate memory from the underlying memory pool. More...
 
static void operator delete (void *)
 Delete a pointer from the underlying memory pool. More...
 

Detailed Description

template<int Ra, int Ca, typename Tb, int Cb>
class stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >

This is a subclass of the vari class for matrix multiplication A * B where A is an N by M matrix of double and B is M by K.

The class stores the structure of each matrix, the double values of A and B, and pointers to the varis for A and B if A or B is a var. It also instantiates and stores pointers to varis for all elements of A * B.

Template Parameters
RaRows for matrix A
CaColumns for matrix A, Rows for matrix B
TbScalar type for matrix B
CbColumns for matrix B

Definition at line 212 of file multiply.hpp.

Constructor & Destructor Documentation

◆ multiply_mat_vari()

template<int Ra, int Ca, typename Tb , int Cb>
stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::multiply_mat_vari ( const Eigen::Matrix< double, Ra, Ca > &  A,
const Eigen::Matrix< Tb, Ca, Cb > &  B 
)
inline

Constructor for multiply_mat_vari.

All memory allocated in ChainableStack's stack_alloc arena.

It is critical for the efficiency of this object that the constructor create new varis that aren't popped onto the var_stack_, but rather are popped onto the var_nochain_stack_. This is controlled to the second argument to vari's constructor.

Parameters
Arow vector
Bvector

Definition at line 240 of file multiply.hpp.

Member Function Documentation

◆ chain()

template<int Ra, int Ca, typename Tb , int Cb>
virtual void stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::chain ( )
inlinevirtual

Apply the chain rule to this variable based on the variables on which it depends.

The base implementation in this class is a no-op.

Reimplemented from stan::math::vari.

Definition at line 268 of file multiply.hpp.

Member Data Documentation

◆ A_cols_

template<int Ra, int Ca, typename Tb , int Cb>
int stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::A_cols_

Definition at line 215 of file multiply.hpp.

◆ A_rows_

template<int Ra, int Ca, typename Tb , int Cb>
int stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::A_rows_

Definition at line 214 of file multiply.hpp.

◆ A_size_

template<int Ra, int Ca, typename Tb , int Cb>
int stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::A_size_

Definition at line 217 of file multiply.hpp.

◆ Ad_

template<int Ra, int Ca, typename Tb , int Cb>
double* stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::Ad_

Definition at line 219 of file multiply.hpp.

◆ B_cols_

template<int Ra, int Ca, typename Tb , int Cb>
int stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::B_cols_

Definition at line 216 of file multiply.hpp.

◆ B_size_

template<int Ra, int Ca, typename Tb , int Cb>
int stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::B_size_

Definition at line 218 of file multiply.hpp.

◆ Bd_

template<int Ra, int Ca, typename Tb , int Cb>
double* stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::Bd_

Definition at line 220 of file multiply.hpp.

◆ variRefAB_

template<int Ra, int Ca, typename Tb , int Cb>
vari** stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::variRefAB_

Definition at line 222 of file multiply.hpp.

◆ variRefB_

template<int Ra, int Ca, typename Tb , int Cb>
vari** stan::math::multiply_mat_vari< double, Ra, Ca, Tb, Cb >::variRefB_

Definition at line 221 of file multiply.hpp.


The documentation for this class was generated from the following file:

     [ Stan Home Page ] © 2011–2018, Stan Development Team.