@@ -2,7 +2,7 @@ using TSVD: tsvd
22using RandomizedLinAlg: rsvd
33
44function matricize (VoV:: Vector{Vector{T}} ) where {T}
5- reduce (hcat, VoV)
5+ return reduce (hcat, VoV)
66end
77
88function _svd (data:: Vector{Vector{T}} ; kwargs... ) where {T}
@@ -38,17 +38,19 @@ mutable struct POD <: AbstractDRProblem
3838 renergy:: Any
3939 spectrum:: Any
4040 # constructors
41- function POD (snaps;
41+ function POD (
42+ snaps;
4243 min_renergy = 1.0 ,
4344 min_nmodes:: Int = 1 ,
44- max_nmodes:: Int = length (snaps[1 ]))
45+ max_nmodes:: Int = length (snaps[1 ])
46+ )
4547 nmodes = min_nmodes
4648 errorhandle (snaps, nmodes, min_renergy, min_nmodes, max_nmodes)
47- new (snaps, min_renergy, min_nmodes, max_nmodes, nmodes, missing , 1.0 , missing )
49+ return new (snaps, min_renergy, min_nmodes, max_nmodes, nmodes, missing , 1.0 , missing )
4850 end
4951 function POD (snaps, nmodes:: Int )
5052 errorhandle (snaps, nmodes, 0.0 , nmodes, nmodes)
51- new (snaps, 0.0 , nmodes, nmodes, nmodes, missing , 1.0 , missing )
53+ return new (snaps, 0.0 , nmodes, nmodes, nmodes, missing , 1.0 , missing )
5254 end
5355end
5456
6668function reduce! (pod:: POD , alg:: SVD )
6769 u, s, v = _svd (pod. snapshots; alg. kwargs... )
6870 pod. nmodes,
69- pod. renergy = determine_truncation (s, pod. min_nmodes, pod. max_nmodes,
70- pod. min_renergy)
71+ pod. renergy = determine_truncation (
72+ s, pod. min_nmodes, pod. max_nmodes,
73+ pod. min_renergy
74+ )
7175 pod. rbasis = u[:, 1 : (pod. nmodes)]
7276 pod. spectrum = s
73- nothing
77+ return nothing
7478end
7579
7680function reduce! (pod:: POD , alg:: TSVD )
@@ -79,7 +83,7 @@ function reduce!(pod::POD, alg::TSVD)
7983 pod. renergy = sum (s) / (sum (s) + (n_max - pod. nmodes) * s[end ])
8084 pod. rbasis = u
8185 pod. spectrum = s
82- nothing
86+ return nothing
8387end
8488
8589function reduce! (pod:: POD , alg:: RSVD )
@@ -88,13 +92,15 @@ function reduce!(pod::POD, alg::RSVD)
8892 pod. renergy = sum (s) / (sum (s) + (n_max - pod. nmodes) * s[end ])
8993 pod. rbasis = u
9094 pod. spectrum = s
91- nothing
95+ return nothing
9296end
9397
9498function Base. show (io:: IO , pod:: POD )
9599 print (io, " POD \n " )
96100 print (io, " Reduction Order = " , pod. nmodes, " \n " )
97- print (io, " Snapshot size = (" , size (pod. snapshots, 1 ), " ," , size (pod. snapshots[1 ], 2 ),
98- " )\n " )
99- print (io, " Relative Energy = " , pod. renergy, " \n " )
101+ print (
102+ io, " Snapshot size = (" , size (pod. snapshots, 1 ), " ," , size (pod. snapshots[1 ], 2 ),
103+ " )\n "
104+ )
105+ return print (io, " Relative Energy = " , pod. renergy, " \n " )
100106end
0 commit comments