Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
starfinder
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Schreiber
starfinder
Commits
e9bbd30d
Commit
e9bbd30d
authored
3 months ago
by
Laura Schreiber
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
487715b2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
svd_inv_matrix.pro
+70
-0
70 additions, 0 deletions
svd_inv_matrix.pro
with
70 additions
and
0 deletions
svd_inv_matrix.pro
0 → 100644
+
70
−
0
View file @
e9bbd30d
;
$
Id
:
svd_inv_matrix
.
pro
#
0.1
$
;
;
+
;
NAME
:
;
SVD_INV_MATRIX
;
;
PURPOSE
:
;
Invert
a
matrix
by
SVD
.
;
;
CATEGORY
:
;
Mathematics
.
;
;
CALLING
SEQUENCE
:
;
Result
=
SVD_INV_MATRIX
(
A
,
Sv
,
Tr
)
;
;
INPUTS
:
;
A
:
Input
matrix
(
floating
-
point
,
single
or
double
precision
).
;
;
KEYWORD
PARAMETERS
:
;
TOL
:
Relative
tolerance
on
singular
values
of
matrix
A
.
;
Singular
values
lower
than
;
tol
*
MAX
(
ABS
(
sv
))
are
set
to
0
in
the
matrix
inversion
.
;
Default
TOL
=
1
e
-
6
.
;
;
DOUBLE
:
set
this
binary
keyword
to
perform
inversion
of
matrix
A
;
in
double
-
precision
.
This
is
the
default
if
A
is
double
-
precision
.
;
;
OUTPUTS
:
;
Returns
inverse
of
A
.
;
;
OPTIONAL
OUTPUTS
:
;
Sv
:
vector
of
singular
values
of
(
AtA
)
;
;
Tr
:
trace
of
(
AtA
)
^-
1
.
;
;
PROCEDURE
:
;
Calculate
generalized
inverse
of
A
by
SVD
.
;
;
MODIFICATION
HISTORY
:
;
Written
by
:
L
.
S
.
(
UniBo
)
2010
;
as
part
of
MODAL_INT_MATRIX
and
ZONAL_INT_MATRIX
;
1
)
E
.
D
.
(
INAF
-
OABo
),
April
2011
:
defined
as
stand
-
alone
routine
.
;
-
function
svd_inv_matrix
,
a
,
TOL
=
tol
,
DOUBLE
=
double
,
sv
,
tr
,
DIAG
=
diag
,
_EXTRA
=
extra
on_error
,
2
if
n_elements
(
tol
)
eq
0
then
tol
=
(
machar
(
DOUBLE
=
double
)).
eps
;
SVD
svdc
,
transpose
(
a
)
##
a
,
sv
,
u
,
v
,
DOUBLE
=
double
,
_EXTRA
=
extra
;
Invert
singular
values
sv_inv
=
sv
sv_min
=
max
(
abs
(
sv
))
*
tol
w
=
where
(
abs
(
sv
)
ge
sv_min
,
n
)
&
if
n
ne
0
then
sv_inv
[
w
]
=
1
/
sv
[
w
]
w
=
where
(
abs
(
sv
)
lt
sv_min
,
n
)
&
if
n
ne
0
then
sv_inv
[
w
]
=
0
;
Invert
matrix
n
=
n_elements
(
sv
)
id
=
identity
(
n
,
DOUBLE
=
double
)
s
=
lindgen
(
n
)
id
[
s
,
s
]
=
sv_inv
b
=
transpose
(
temporary
(
v
))
#
temporary
(
id
)
#
temporary
(
u
)
;
b
=
transpose
(
v
)
#
id
#
u
tr
=
trace
(
b
)
diag
=
diag_matrix
(
b
)
b
=
temporary
(
b
)
##
transpose
(
a
)
return
,
b
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment