Toast++  1.0.2 (r.539)
Forward and inverse modelling in optical tomography
jacobian_mpi.h
1 // -*-C++-*-
2 // =========================================================================
3 // jacobian.h (libstoast)
4 // Interface for Jacobian calculation
5 //
6 // Jacobian of forward operator: derivative of measurables with respect to
7 // parameters (frequency domain case)
8 // The Jacobian is a real matrix is composed of 4 blocks:
9 //
10 // | dlnamp | dlnamp |
11 // | ------ | ------ |
12 // | dmua | dkappa |
13 // |----------+----------|
14 // | dphase | dphase |
15 // | ------ | ------ |
16 // | dmua | dkappa |
17 //
18 // Each row corresponds to a measurement (source-detector pair), each column
19 // corresponds to a voxel in solution space.
20 // The returned Jacobian does not contain any data or parameter scalings.
21 // =========================================================================
22 
23 #ifndef __JACOBIANMPI_H
24 #define __JACOBIANMPI_H
25 
26 #include "mathlib.h"
27 #include "felib.h"
28 #include "toasttype.h"
29 
38 
53 STOASTLIB void GenerateJacobian (const Raster *raster, const QMMesh *mesh,
54  const CCompRowMatrix &mvec, const CVector *dphi, const CVector *aphi,
55  DataScale dscale, RDenseMatrixMPI &Jmod, RDenseMatrixMPI &Jarg);
56 
70 STOASTLIB void GenerateJacobian (const Raster *raster, const QMMesh *mesh,
71  const CVector *dphi, const CVector *aphi, const CVector *proj,
72  DataScale dscale, RDenseMatrixMPI &Jmod, RDenseMatrixMPI &Jarg);
73 
87 STOASTLIB void GenerateJacobian_cw_mua (const Raster *raster,
88  const QMMesh *mesh, const RCompRowMatrix &mvec,
89  const RVector *dphi, const RVector *aphi,
90  DataScale dscale, RDenseMatrixMPI &J);
91 
93 
94 // ============================================================================
95 // PMDF calculations
96 
97 // absorption PMDF
98 template<class T>
99 inline TVector<T> PMDF_mua (const TVector<T> &dphi, const TVector<T> &aphi)
100 {
101  return -dphi*aphi;
102 }
103 
104 // diffusion PMDF
105 template<class T>
106 inline TVector<T> PMDF_kap (const TVector<T> *Gdphi, const TVector<T> *Gaphi,
107  int dim)
108 {
109  TVector<T> pmdf(Gdphi[0].Dim());
110  for (int j = 0; j < dim; j++)
111  pmdf -= Gdphi[j]*Gaphi[j];
112  return pmdf;
113 }
114 
115 // convert to log data PMDF for measurement m
116 template<class T>
117 inline TVector<T> PMDF_log (const TVector<T> &pmdf, T &m)
118 {
119  return pmdf/m;
120 }
121 
122 
123 template<class T>
124 void ImageGradient (const IVector &dim, const RVector &size,
125  const TVector<T> &im, TVector<T> *grad, const int *mask = 0);
126 
127 #endif // !__JACOBIANMPI_H
STOASTLIB void GenerateJacobian(const Raster *raster, const QMMesh *mesh, const CCompRowMatrix &mvec, const CVector *dphi, const CVector *aphi, DataScale dscale, RDenseMatrixMPI &Jmod, RDenseMatrixMPI &Jarg)
Generate Jacobian matrix of forward operator (complex case)
DataScale
Definition: fwdsolver.h:27
Base class for mapping between mesh and an independent basis representation.
Definition: raster.h:20
Definition: qmmesh.h:22
Compressed-row sparse matrix class.
Definition: cdmatrix.h:27
Distributed dense matrix class.
Definition: dnsmatrix_mpi.h:32
STOASTLIB void GenerateJacobian_cw_mua(const Raster *raster, const QMMesh *mesh, const RCompRowMatrix &mvec, const RVector *dphi, const RVector *aphi, DataScale dscale, RDenseMatrixMPI &J)
Generate Jacobian matrix for CW intensity data (real case).