imate
C++/CUDA Reference
Loading...
Searching...
No Matches
c_affine_matrix_function.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
3 * SPDX-License-Identifier: BSD-3-Clause
4 * SPDX-FileType: SOURCE
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the license found in the LICENSE.txt file in the root
8 * directory of this source tree.
9 */
10
11
12// =======
13// Headers
14// =======
15
17#include <cassert> // assert
18#include "../_c_basic_algebra/c_vector_operations.h" // cVectorOperations
19
20
21// ===========
22// constructor
23// ===========
24
27
28template <typename DataType>
30 B_is_identity(false)
31{
32 // This class has one parameter that is t in A+tB
33 this->num_parameters = 1;
34}
35
36
37// ==========
38// destructor
39// ==========
40
43
44template <typename DataType>
48
49
50// ==============
51// get eigenvalue
52// ==============
53
90
91template <typename DataType>
93 const DataType* known_parameters,
94 const DataType known_eigenvalue,
95 const DataType* inquiry_parameters) const
96{
97 assert((this->eigenvalue_relation_known == 1) && \
98 "An eigenvalue relation is not known. This function should be "
99 "called only when the matrix B is a scalar multiple of the "
100 "identity matrix");
101
102 // Shift the eigenvalue by the parameter
103 DataType inquiry_eigenvalue = \
104 known_eigenvalue - known_parameters[0] + inquiry_parameters[0];
105
106 return inquiry_eigenvalue;
107}
108
109
110// =================
111// add scaled vector
112// =================
113
128
129template <typename DataType>
131 const DataType* input_vector,
132 const LongIndexType vector_size,
133 const DataType scale,
134 DataType* output_vector) const
135{
136 // Subtracting two vectors with minus scale sign, which is adding.
138 input_vector, vector_size, -scale, output_vector);
139}
140
141
142// ===============================
143// Explicit template instantiation
144// ===============================
145
146template class cAffineMatrixFunction<float>;
147template class cAffineMatrixFunction<double>;
Base class for affine matrix functions of one parameter.
void _add_scaled_vector(const DataType *input_vector, const LongIndexType vector_size, const DataType scale, DataType *output_vector) const
Performs the operation , where is an input vector scaled by and it the output vector.
virtual ~cAffineMatrixFunction()
Virtual destructor.
DataType get_eigenvalue(const DataType *known_parameters, const DataType known_eigenvalue, const DataType *inquiry_parameters) const
This function defines an analytic relationship between a given set of parameters and the correspondin...
static void subtract_scaled_vector(const DataType *RESTRICT input_vector, const LongIndexType vector_size, const DataType scale, DataType *RESTRICT output_vector)
Subtracts the scaled input vector from the output vector.
int LongIndexType
Definition types.h:60