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
b68784a5
Commit
b68784a5
authored
8 years ago
by
Nicolas Bellot
Committed by
hhakim
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
demo matlab : norm_hadamard ajoute
parent
7bd536ff
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
misc/demo/Hadamard_factorization/norm_hadamard.m
+194
-0
194 additions, 0 deletions
misc/demo/Hadamard_factorization/norm_hadamard.m
misc/demo/run_all_demo.m
+2
-1
2 additions, 1 deletion
misc/demo/run_all_demo.m
misc/demo/tools/hadamard_mat.m
+4
-3
4 additions, 3 deletions
misc/demo/tools/hadamard_mat.m
with
200 additions
and
4 deletions
misc/demo/Hadamard_factorization/norm_hadamard.m
0 → 100644
+
194
−
0
View file @
b68784a5
%% Description norm_hadamard
%
% This demo makes some time comparison between the 2-norm of the Hadamard matrix and
% her Faust representation for different dimension
% of the Hadamard matrix.
%
% For more information on the FAuST Project, please visit the website of
% the project : <http://faust.gforge.inria.fr>
%
%% License:
% Copyright (2016): Luc Le Magoarou, Remi Gribonval
% INRIA Rennes, FRANCE
% http://www.inria.fr/
%
% The FAuST Toolbox is distributed under the terms of the GNU Affero
% General Public License.
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU Affero General Public License as published
% by the Free Software Foundation.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% See the GNU Affero General Public License for more details.
%
% You should have received a copy of the GNU Affero General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
%% Contacts:
% Nicolas Bellot : nicolas.bellot@inria.fr
% Leman Adrien : adrien.leman@inria.fr
% Luc Le Magoarou: luc.le-magoarou@inria.fr
% Remi Gribonval : remi.gribonval@inria.fr
%
%% References:
% [1] Le Magoarou L. and Gribonval R., "Flexible multi-layer sparse
% approximations of matrices and applications", Journal of Selected
% Topics in Signal Processing, 2016.
% <https://hal.archives-ouvertes.fr/hal-01167948v1>
%%
nb_mult
=
10
;
Ms
=
6
:
11
;
ns
=
2.
^
Ms
;
nb_dim
=
length
(
Ms
);
threshold
=
10
^
(
-
10
);
h
=
waitbar
(
0
,
'speed up hadamard : Generation of the data ...'
);
Hadamard_matrices
=
cell
(
1
,
nb_dim
);
Hadamard_facts
=
cell
(
1
,
nb_dim
);
for
k
=
1
:
nb_dim
waitbar
(
k
/
nb_dim
);
M
=
Ms
(
k
);
n
=
ns
(
k
);
% generation of the hadamard factorisation
[
H
,
facts
]
=
hadamard_mat
(
M
);
Hadamard_matrices
{
k
}
=
H
;
Hadamard_facts
{
k
}
=
facts
;
end
close
(
h
);
dense_times
=
zeros
(
nb_mult
,
nb_dim
);
faust_times
=
zeros
(
nb_mult
,
nb_dim
);
norm_dense
=
zeros
(
1
,
nb_dim
);
norm_faust
=
zeros
(
1
,
nb_dim
);
RCGs
=
ns
.
/(
Ms
*
2
);
h
=
waitbar
(
0
,
'2-norm hadamard : multiplication time comparison ...'
);
for
i
=
1
:
nb_mult
waitbar
(
i
/
nb_mult
);
for
k
=
1
:
nb_dim
n
=
ns
(
k
);
hadamard_dense
=
Hadamard_matrices
{
k
};
hadamard_faust
=
Faust
(
Hadamard_facts
{
k
});
%% 2-norm of the hadamard matrix
tic
norm_dense
(
k
)
=
norm
(
hadamard_dense
);
t1
=
toc
;
tic
norm_faust
(
k
)
=
norm
(
hadamard_faust
);
t2
=
toc
;
dense_times
(
i
,
k
)
=
t1
;
faust_times
(
i
,
k
)
=
t2
;
end
end
close
(
h
);
mean_dense_t
=
mean
(
dense_times
);
mean_faust_t
=
mean
(
faust_times
);
speed_up
=
mean_dense_t
.
/
mean_faust_t
;
% expected_norm = ones(1,nb_dim); % version orthonormee
expected_norm
=
2.
^
(
Ms
/
2
);
% version non orthonormée
err_norm_dense
=
sqrt
((
norm_dense
-
expected_norm
)
.^
2
);
err_norm_faust
=
sqrt
((
norm_faust
-
expected_norm
)
.^
2
);
disp
([
'speed-up : '
num2str
(
speed_up
)]);
disp
([
'norm dense : '
num2str
(
norm_dense
(
1
,:))]);
disp
([
'norm faust : '
num2str
(
norm_faust
(
1
,:))]);
%% Plot the result
plot_tickness
=
2.0
;
legend_location
=
'NorthWest'
;
f
=
figure
;
% runtime comparison
subplot
(
1
,
3
,
1
);
semilogy
(
Ms
,
mean_faust_t
,
'linewidth'
,
plot_tickness
);
hold
on
semilogy
(
Ms
,
mean_dense_t
,
'r'
,
'linewidth'
,
plot_tickness
);
ymin
=
min
([
mean_dense_t
,
mean_faust_t
]);
ymax
=
max
([
mean_dense_t
,
mean_faust_t
]);
grid
on
axis
([
Ms
(
1
)
Ms
(
end
)
ymin
ymax
]);
legend
(
'faust'
,
'dense'
,
'Location'
,
legend_location
);
ylabel
(
'Computed Time (sec)'
);
xlabel
(
'log(dim)'
);
title
(
'runtime '
);
set
(
gca
,
'XTick'
,
Ms
);
% speed-up
subplot
(
1
,
3
,
2
);
semilogy
(
Ms
,
speed_up
,
'linewidth'
,
plot_tickness
);
hold
on
semilogy
(
Ms
,
ones
(
1
,
nb_dim
),
'k'
,
'linewidth'
,
plot_tickness
);
semilogy
(
Ms
,
RCGs
,
'g'
,
'linewidth'
,
plot_tickness
);
grid
on
axis
([
Ms
(
1
)
Ms
(
end
)
min
([
speed_up
,
1
,
RCGs
])
max
([
speed_up
,
1
,
RCGs
])]);
title
(
'speed-up norm(A)'
);
xlabel
(
'log(dim)'
);
ylabel
(
'speedup'
);
legend
(
'faust'
,
'neutral'
,
'theoretical'
,
'Location'
,
legend_location
);
set
(
gca
,
'XTick'
,
Ms
);
%%
subplot
(
1
,
3
,
3
);
id
=
find
(
err_norm_faust
~=
0
);
% semilogy is not compatible with 0
semilogy
(
Ms
(
id
),
err_norm_faust
(
id
),
'r+-'
,
'linewidth'
,
plot_tickness
);
hold
on
semilogy
(
Ms
,
err_norm_dense
,
'linewidth'
,
plot_tickness
);
ymin
=
min
([
err_norm_dense
,
err_norm_faust
]);
ymax
=
max
([
err_norm_dense
,
err_norm_faust
]);
grid
on
%axis([Ms(1) Ms(end) ymin ymax]);
legend
(
'faust'
,
'dense'
,
'Location'
,
legend_location
);
ylabel
(
'Computed Time (sec)'
);
xlabel
(
'log(dim)'
);
title
(
'error '
);
set
(
gca
,
'XTick'
,
Ms
);
f
.
Name
=
[
'Hadamard 2-norm'
];
%% save the figure
runPath
=
which
(
mfilename
);
pathname
=
fileparts
(
runPath
);
figure_dir
=
[
pathname
filesep
'..'
filesep
'Figures'
];
format_fig
=
'-dpng'
;
figure_name
=
[
figure_dir
filesep
'Hadamard-norm'
];
print
(
figure_name
,
format_fig
);
This diff is collapsed.
Click to expand it.
misc/demo/run_all_demo.m
+
2
−
1
View file @
b68784a5
...
...
@@ -53,7 +53,8 @@ Fig_BSL;
%% Hadamard factorization
disp
(
'*********** Hadamard Factorization *************'
);
demo_fact_hadamard
;
speed_up_hadamard
;
speed_up_hadamard
;
norm_hadamard
;
%% Runtime comparison
...
...
This diff is collapsed.
Click to expand it.
misc/demo/tools/hadamard_mat.m
+
4
−
3
View file @
b68784a5
...
...
@@ -41,9 +41,10 @@
function
[
H
,
Fact
]
=
hadamard_mat
(
M
)
bloc
=
(
1
/
sqrt
(
2
))
*
[
1
1
;
1
-
1
];
matbase
=
bloc
;
matbase
=
kron
(
speye
(
2
^
(
M
-
1
)),
matbase
);
% bloc = (1/sqrt(2))*[1 1;1 -1]; % normalized version
bloc
=
[
1
1
;
1
-
1
];
% non-normalized version
matbase
=
kron
(
speye
(
2
^
(
M
-
1
)),
bloc
);
n
=
size
(
matbase
,
1
);
L
=
(
1
:
n
/
2
);
...
...
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