-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextendedState2basisFunctions.m
52 lines (48 loc) · 1.58 KB
/
extendedState2basisFunctions.m
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
47
48
49
50
51
52
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This script uses the nomenclature, formulations and solutions from:
% M. Avillez and D. Arnas, "Constructing Linear Operators Using Classical
% Perturbation Theory", TODO
%
% Summary:
% Given an extended state, computes the value of the basis functions,
% according to the definition of the basis function specified through
% mons.
%
% Inputs:
% mons: array representing a set of monomials. Each row
% represents one monomial, with each coefficient being the exponent
% of the associated element of the extended state. E.g.: If the
% extended state is [x,y,z], a row [1,0,2] represents x*z^2.
% extendedState: Value of the extended state
%
% Outputs:
% basisFunctions: Value of the basis functions
%
%
% Authors: Miguel Avillez and David Arnas
% Modified: May 2024
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function basisFunctions = extendedState2basisFunctions(mons, extendedState)
if length(extendedState) ~= size(mons,2)
error("Size of initial state (%d) and number of dimensions (%d) is inconsistent.\n", ...
length(extendedState), size(mons,2));
end
basisFunctions = zeros(size(mons,1),1);
% Loop over basis functions
for i = 1:size(mons,1)
if nnz(mons(i,:)) == 0
ic = 0;
else
ic = 1;
% Loop over extended state elements
for j = 1:size(mons,2)
if mons(i,j) ~= 0
ic = ic * extendedState(j)^mons(i,j);
end
end
end
basisFunctions(i) = ic;
end
end