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
2922fbe3
Commit
2922fbe3
authored
6 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Update GivensFGFT skeleton.
parent
d9c91526
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_GivensFGFT.h
+39
-5
39 additions, 5 deletions
src/algorithm/factorization/faust_GivensFGFT.h
src/algorithm/factorization/faust_GivensFGFT.hpp
+116
-6
116 additions, 6 deletions
src/algorithm/factorization/faust_GivensFGFT.hpp
with
155 additions
and
11 deletions
src/algorithm/factorization/faust_GivensFGFT.h
+
39
−
5
View file @
2922fbe3
...
...
@@ -9,20 +9,54 @@
namespace
Faust
{
template
<
typename
FPP
,
Device
DEVICE
>
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
=
float
>
class
GivensFGFT
{
vector
<
Faust
::
MatSparse
<
FPP
,
DEVICE
>>
facts
;
Faust
::
MatSparse
<
FPP
,
DEVICE
>
D
;
Faust
::
MatSparse
<
FPP
,
DEVICE
>
C
;
vector
<
float
>
err
;
vector
<
pair
<
int
,
int
>>
coord_choices
;
Faust
::
MatDense
<
FPP
,
DEVICE
>
L
;
vector
<
FPP2
>
errs
;
vector
<
pair
<
faust_unsigned_int
,
faust_unsigned_int
>>
coord_choices
;
Faust
::
MatDense
<
FPP
,
DEVICE
>
Lap
;
faust_unsigned_int
p
,
q
;
public:
GivensFGFT
(
Faust
::
MatDense
<
FPP
,
DEVICE
>&
Lap
,
unsigned
int
j
);
GivensFGFT
(
Faust
::
MatDense
<
FPP
,
DEVICE
>&
Lap
,
faust_unsigned_int
J
);
/**
* \brief Algo. main step.
*/
void
next_step
();
void
compute_facts
();
/** \brief Algo. step 2.1.
*/
void
choose_pivot
();
/** \brief Algo. step 2.1.1
*
*/
void
sort_L_in_C
();
/** \brief Algo. step 2.2.
*/
void
calc_theta
();
/**
* \brief Algo. step 2.3.
*/
void
update_fact
();
/**
* \brief ALgo. step 2.4
*/
void
update_L
();
/**
* \brief Algo. step 2.5.
*/
void
update_D
();
/**
* \brief Algo. step 2.6.
*/
void
calc_err
();
};
...
...
This diff is collapsed.
Click to expand it.
src/algorithm/factorization/faust_GivensFGFT.hpp
+
116
−
6
View file @
2922fbe3
template
<
typename
FPP
,
Device
DEVICE
>
void
Faust
::
GivensFGFT
<
FPP
,
DEVICE
>::
next_step
()
using
namespace
Faust
;
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
>
void
GivensFGFT
<
FPP
,
DEVICE
,
FPP2
>::
next_step
()
{
}
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
>
void
GivensFGFT
<
FPP
,
DEVICE
,
FPP2
>::
choose_pivot
()
{
//Matlab ref. code:
// [~,p] = min(C_min_row);
// q = q_candidates(p);
// coord_choices(1,j) = p;
// coord_choices(2,j) = q;
}
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
>
void
GivensFGFT
<
FPP
,
DEVICE
,
FPP2
>::
sort_L_in_C
()
{
// Matlab ref. code:
//************** at initialization
// for r=1:n
// for s=r+1:n
// C(r,s) = -abs(L(r,s));%-2*L(r,s)^2;
// end
// end
// [C_min_row, q_candidates] = min(C,[],2);
//
/************ at end of ite.
* for r=[p,q]
* for s=r+1:n
* C(r,s) = -abs(L(r,s));%-2*L(r,s)^2;
* end
* [C_min_row(r), q_candidates(r)] = min(C(r,:));
* end
*
* for s=[p,q]
* for r=1:s-1
* C(r,s) = -abs(L(r,s));%-2*L(r,s)^2;
* if C(r,s)<C_min_row(r)
* C_min_row(r) = C(r,s);
* q_candidates(r) = s;
* elseif q_candidates(r) == s
* [C_min_row(r), q_candidates(r)] = min(C(r,:));
* end
* end
* end
*/
}
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
>
void
GivensFGFT
<
FPP
,
DEVICE
,
FPP2
>::
calc_theta
()
{
// Matlab ref. code:
// theta1 = atan2(L(q,q) - L(p,p),2*L(p,q))/2 ;
// err_theta1 = (L(p,q)*cos(2*theta1) + 0.5*(L(q,q) - L(p,p))*sin(2*theta1))^2;
// theta2 = atan2(L(q,q) - L(p,p),2*L(p,q))/2 + pi/4;
// err_theta2 = (L(p,q)*cos(2*theta2) + 0.5*(L(q,q) - L(p,p))*sin(2*theta2))^2;
// if err_theta1<err_theta2
// theta=theta1;
// else
// theta=theta2;
// end
}
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
>
void
GivensFGFT
<
FPP
,
DEVICE
,
FPP2
>::
update_fact
()
{
// Matlab ref. code:
// S = eye(n);
// S(p,p) = cos(theta); S(p,q) = -sin(theta);
// S(q,p) = sin(theta); S(q,q) = cos(theta);
// S = sparse(S);
// facts{j} = S;
//
}
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
>
void
GivensFGFT
<
FPP
,
DEVICE
,
FPP2
>::
update_L
()
{
// L = S'*L*S
}
template
<
typename
FPP
,
Device
DEVICE
>
void
Faust
::
GivensFGFT
<
FPP
,
DEVICE
>::
compute_facts
()
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
>
void
GivensFGFT
<
FPP
,
DEVICE
,
FPP2
>::
update_D
()
{
// D = spdiag(diag(L))
}
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
>
void
GivensFGFT
<
FPP
,
DEVICE
,
FPP2
>::
calc_err
()
{
// Matlab ref. code:
// if mod(j,100)==0
// %err(j) = norm(D-L,'fro')^2/norm(L,'fro')^2;
// err(j) = norm(D-L,'fro')^2/norm(Lap,'fro')^2;
// %err(j) = norm(D-L)/norm(Lap);
// disp(['Iter ' num2str(j) ', error = ' num2str(err(j))])
// % disp(['Number of edges: ' num2str(N_edges)])
// end
//
}
template
<
typename
FPP
,
Device
DEVICE
>
Faust
::
GivensFGFT
<
FPP
,
DEVICE
>::
GivensFGFT
(
Faust
::
MatDense
<
FPP
,
DEVICE
>&
Lap
,
unsigned
int
j
)
:
L
(
Lap
),
facts
(
j
),
D
(
Lap
.
getNbRow
(),
Lap
.
getNbCol
()),
C
(
Lap
.
getNbRow
(),
Lap
.
getNbRow
()),
err
(
j
),
coord_choice
s
(
j
)
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
>
void
GivensFGFT
<
FPP
,
DEVICE
,
FPP2
>::
compute_fact
s
()
{
}
template
<
typename
FPP
,
Device
DEVICE
,
typename
FPP2
>
GivensFGFT
<
FPP
,
DEVICE
,
FPP2
>::
GivensFGFT
(
Faust
::
MatDense
<
FPP
,
DEVICE
>&
Lap
,
faust_unsigned_int
J
)
:
Lap
(
Lap
),
facts
(
J
),
D
(
Lap
.
getNbRow
(),
Lap
.
getNbCol
()),
C
(
Lap
.
getNbRow
(),
Lap
.
getNbRow
()),
errs
(
J
),
coord_choices
(
J
)
{
/** Matlab ref. code:
* facts = cell(1,J);
* n=size(Lap,1);
* L=Lap;
* C = 15*ones(n);
* err=zeros(1,J);
* coord_choices = zeros(2,J);
*
*/
}
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