-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnormal_matrix.h
46 lines (35 loc) · 1.4 KB
/
normal_matrix.h
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
43
44
45
46
// Copyright (c) 2018 ERGO-Code. See license.txt for license.
#ifndef IPX_NORMAL_MATRIX_H_
#define IPX_NORMAL_MATRIX_H_
#include "linear_operator.h"
#include "model.h"
namespace ipx {
// NormalMatrix provides matrix-vector operations with the matrix
//
// AI*W*AI',
//
// where AI is the m-by-(n+m) matrix defined by the model, and W is a diagonal
// (weight) matrix defined by the user.
class NormalMatrix : public LinearOperator {
public:
// Constructor stores a reference to the model. No data is copied. The model
// must be valid as long as the object is used.
explicit NormalMatrix(const Model& model);
// Prepares normal matrix for subsequent calls to Apply(). If W is not NULL,
// then W must hold n+m entries. No data is copied. The array must be valid
// in each subsequent call to Apply(). If W is NULL, then the first n
// entries are assumed 1.0 and the last m entries are assumed 0.0.
void Prepare(const double* W);
// Returns computation time for calls to Apply() since last reset_time().
double time() const;
void reset_time();
private:
void _Apply(const Vector& rhs, Vector& lhs, double* rhs_dot_lhs) override;
const Model& model_;
const double* W_{nullptr};
bool prepared_{false};
Vector work_; // size n+m workspace (2-pass matvec products only)
double time_{0.0};
};
} // namespace ipx
#endif // IPX_NORMAL_MATRIX_H_