-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcovariance_cache.h
More file actions
42 lines (32 loc) · 1.38 KB
/
covariance_cache.h
File metadata and controls
42 lines (32 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
/* covariance_cache.h - Part of the spatial VB framework
Adrian Groves & Michael Chappell, FMRIB Image Analysis Group & IBME QuBIc Group
Copyright (C) 2007-2015 University of Oxford */
/* CCOPYRIGHT */
#include "easylog.h"
#include "armawrap/newmat.h"
#include <map>
#include <string>
#include <utility>
class CovarianceCache : public Loggable
{
public:
void CalcDistances(const NEWMAT::Matrix &voxelCoords, const std::string &distanceMeasure);
const NEWMAT::SymmetricMatrix &GetDistances() const;
const NEWMAT::ReturnMatrix GetC(double delta) const; // quick to calculate
const NEWMAT::SymmetricMatrix &GetCinv(double delta) const;
const NEWMAT::SymmetricMatrix &GetCiCodistCi(double delta, double *CiCodistTrace = NULL) const;
/**
* If there's a cached value in (lower, upper), set *guess = value and
* return true; otherwise return false and don't change *guess.
*/
bool GetCachedInRange(
double *guess, double lower, double upper, bool allowEndpoints = false) const;
private:
typedef std::map<double, NEWMAT::SymmetricMatrix> Cinv_cache_type;
typedef std::map<double, std::pair<NEWMAT::SymmetricMatrix, double> > CiCodistCi_cache_type;
NEWMAT::SymmetricMatrix m_distances;
mutable Cinv_cache_type m_cinv_cache;
mutable NEWMAT::SymmetricMatrix m_cinv;
mutable CiCodistCi_cache_type CiCodistCi_cache;
};