Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
faust group
faust
Commits
136e98a0
Commit
136e98a0
authored
5 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Refactor palm4msa2020 by using MatDense::adjoint() and new function fill_of_eyes().
parent
f7b45660
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/algorithm/factorization/faust_palm4msa2020.h
+15
-0
15 additions, 0 deletions
src/algorithm/factorization/faust_palm4msa2020.h
src/algorithm/factorization/faust_palm4msa2020.hpp
+62
-58
62 additions, 58 deletions
src/algorithm/factorization/faust_palm4msa2020.hpp
with
77 additions
and
58 deletions
src/algorithm/factorization/faust_palm4msa2020.h
+
15
−
0
View file @
136e98a0
...
...
@@ -53,6 +53,21 @@ namespace Faust
const
unsigned
int
norm2_max_iter
=
FAUST_NORM2_MAX_ITER
,
const
bool
constant_step_size
=
false
,
const
Real
<
FPP
>
step_size
=
FAUST_PRECISION
);
/**
* \brief Fill S with nfacts eye() matrices.
*
* S must be an empty Faust. If S is already composed of factors an exception is raised.
*
* \param sparse if true eyes are MatSparse, they are MatDense otherwise.
*
*/
template
<
typename
FPP
,
FDevice
DEVICE
>
void
fill_of_eyes
(
Faust
::
TransformHelper
<
FPP
,
DEVICE
>&
S
,
const
unsigned
int
nfacts
,
const
bool
sparse
,
const
std
::
vector
<
std
::
pair
<
faust_unsigned_int
,
faust_unsigned_int
>>
dims
);
//TODO: maybe move this function in a Faust::utils module (for now it serves only for PALM4MSA)
}
#include
"faust_palm4msa2020.hpp"
#endif
This diff is collapsed.
Click to expand it.
src/algorithm/factorization/faust_palm4msa2020.hpp
+
62
−
58
View file @
136e98a0
...
...
@@ -25,32 +25,33 @@ void Faust::palm4msa(const Faust::MatDense<FPP,DEVICE>& A,
for
(
auto
c
:
constraints
)
dims
.
push_back
(
make_pair
(
c
->
get_rows
(),
c
->
get_cols
()));
Faust
::
MatDense
<
FPP
,
DEVICE
>
A_H
=
A
;
A_H
.
conjugate
(
false
);
A_H
.
transpose
();
A_H
.
adjoint
();
// if(S.size() != nfacts)
// {
//// S = Faust::TransformHelper<FPP,DEVICE>();
// //TODO: refactor the id factor gen. into TransformHelper
// for(auto fdims : dims)
// {
// // init all facts as identity matrices
// // with proper dimensions
// Faust::MatGeneric<FPP,DEVICE>* fact;
// if(use_csr)
// {
// auto sfact = new Faust::MatSparse<FPP,DEVICE>(fdims.first, fdims.second);
// sfact->setEyes();
// fact = sfact;
// }
// else
// {
// auto dfact = new Faust::MatDense<FPP,DEVICE>(fdims.first, fdims.second);
// dfact->setEyes();
// fact = dfact;
// }
// S.push_back(fact); //TODO: copying=false
// }
// }
if
(
S
.
size
()
!=
nfacts
)
{
// S = Faust::TransformHelper<FPP,DEVICE>();
//TODO: refactor the id factor gen. into TransformHelper
for
(
auto
fdims
:
dims
)
{
// init all facts as identity matrices
// with proper dimensions
Faust
::
MatGeneric
<
FPP
,
DEVICE
>*
fact
;
if
(
use_csr
)
{
auto
sfact
=
new
Faust
::
MatSparse
<
FPP
,
DEVICE
>
(
fdims
.
first
,
fdims
.
second
);
sfact
->
setEyes
();
fact
=
sfact
;
}
else
{
auto
dfact
=
new
Faust
::
MatDense
<
FPP
,
DEVICE
>
(
fdims
.
first
,
fdims
.
second
);
dfact
->
setEyes
();
fact
=
dfact
;
}
S
.
push_back
(
fact
);
//TODO: copying=false
}
}
fill_of_eyes
(
S
,
nfacts
,
use_csr
,
dims
);
int
i
=
0
,
f_id
;
std
::
function
<
void
()
>
init_fid
,
next_fid
;
std
::
function
<
bool
()
>
updating_facs
;
...
...
@@ -107,11 +108,9 @@ void Faust::palm4msa(const Faust::MatDense<FPP,DEVICE>& A,
if
(
sc
.
isCriterionErr
())
error
=
tmp
.
norm
();
//TODO: do something to lighten the double transpose conjugate
tmp
.
conjugate
(
false
);
tmp
.
transpose
();
tmp
.
adjoint
();
tmp
=
R
->
multiply
(
tmp
,
/* H */
false
,
false
);
tmp
.
conjugate
(
false
);
tmp
.
transpose
();
tmp
.
adjoint
();
tmp
*=
lambda
/
c
;
D
-=
tmp
;
};
...
...
@@ -185,11 +184,9 @@ void Faust::palm4msa(const Faust::MatDense<FPP,DEVICE>& A,
if
(
sc
.
isCriterionErr
())
error
=
tmp
.
norm
();
//TODO: do something to lighten the double transpose conjugate
tmp
.
conjugate
(
false
);
tmp
.
transpose
();
tmp
.
adjoint
();
tmp
=
R
->
multiply
(
tmp
,
/* NO H */
false
,
false
);
tmp
.
conjugate
(
false
);
tmp
.
transpose
();
tmp
.
adjoint
();
tmp
=
L
->
multiply
(
tmp
,
true
,
true
);
tmp
*=
lambda
/
c
;
D
-=
tmp
;
...
...
@@ -268,32 +265,9 @@ void Faust::palm4msa2(const Faust::MatDense<FPP,DEVICE>& A,
dims
.
push_back
(
make_pair
(
c
->
get_rows
(),
c
->
get_cols
()));
//TODO: make it possible to have a MatSparse A
Faust
::
MatDense
<
FPP
,
DEVICE
>
A_H
=
A
;
A_H
.
conjugate
(
false
);
A_H
.
transpose
();
A_H
.
adjoint
();
if
(
S
.
size
()
!=
nfacts
)
{
// S = Faust::TransformHelper<FPP,DEVICE>();
//TODO: refactor the id factor gen. into TransformHelper
for
(
auto
fdims
:
dims
)
{
// init all facts as identity matrices
// with proper dimensions
Faust
::
MatGeneric
<
FPP
,
DEVICE
>*
fact
;
if
(
use_csr
)
{
auto
sfact
=
new
Faust
::
MatSparse
<
FPP
,
DEVICE
>
(
fdims
.
first
,
fdims
.
second
);
sfact
->
setEyes
();
fact
=
sfact
;
}
else
{
auto
dfact
=
new
Faust
::
MatDense
<
FPP
,
DEVICE
>
(
fdims
.
first
,
fdims
.
second
);
dfact
->
setEyes
();
fact
=
dfact
;
}
S
.
push_back
(
fact
);
//TODO: copying=false
}
}
fill_of_eyes
(
S
,
nfacts
,
use_csr
,
dims
);
int
i
=
0
,
f_id
;
std
::
function
<
void
()
>
init_ite
,
next_fid
;
std
::
function
<
bool
()
>
updating_facs
;
...
...
@@ -476,3 +450,33 @@ void Faust::palm4msa2(const Faust::MatDense<FPP,DEVICE>& A,
}
S
.
update_total_nnz
();
}
template
<
typename
FPP
,
FDevice
DEVICE
>
void
Faust
::
fill_of_eyes
(
Faust
::
TransformHelper
<
FPP
,
DEVICE
>&
S
,
const
unsigned
int
nfacts
,
const
bool
sparse
,
const
std
::
vector
<
std
::
pair
<
faust_unsigned_int
,
faust_unsigned_int
>>
dims
)
{
if
(
S
.
size
()
>
0
)
throw
std
::
runtime_error
(
"The Faust must be empty for intializing it to eyes factors."
);
for
(
auto
fdims
:
dims
)
{
// init all facts as identity matrices
// with proper dimensions
Faust
::
MatGeneric
<
FPP
,
DEVICE
>*
fact
;
if
(
sparse
)
{
auto
sfact
=
new
Faust
::
MatSparse
<
FPP
,
DEVICE
>
(
fdims
.
first
,
fdims
.
second
);
sfact
->
setEyes
();
fact
=
sfact
;
}
else
{
auto
dfact
=
new
Faust
::
MatDense
<
FPP
,
DEVICE
>
(
fdims
.
first
,
fdims
.
second
);
dfact
->
setEyes
();
fact
=
dfact
;
}
S
.
push_back
(
fact
);
//TODO: copying=false
}
}
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