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
85c82b31
Commit
85c82b31
authored
3 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Add matfaust.rand_butterfly.
parent
3ff17375
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
wrapper/matlab/+matfaust/rand_butterfly.m
+81
-0
81 additions, 0 deletions
wrapper/matlab/+matfaust/rand_butterfly.m
with
81 additions
and
0 deletions
wrapper/matlab/+matfaust/rand_butterfly.m
0 → 100644
+
81
−
0
View file @
85c82b31
%====================================
%> @brief Returns F, a random butterfly support Faust. Each factor is a butterfly factor.
%>
%> @param n: the power of two exponent, that is size(F, 2) == size(F, 1) == 2^n.
%> @param 'dev', str: 'gpu or 'cpu' to create the Faust on CPU or GPU ('cpu' by default).
%> @param 'field', str str is either 'real' or 'complex' (the Faust field).
%> The default value is 'real'.
%> @param 'class', str 'double' (by default) or 'single' to select the scalar type used for the Faust generated.
%>
%> @retval F a random butterfly support Faust.
%====================================
function
F
=
rand_butterfly
(
n
,
varargin
)
import
matfaust
.
dft
argc
=
length
(
varargin
);
dev
=
'cpu'
;
class
=
'double'
;
field
=
'real'
;
if
(
argc
>
0
)
for
i
=
1
:
2
:
argc
if
(
argc
>
i
)
% next arg (value corresponding to the key varargin{i})
tmparg
=
varargin
{
i
+
1
};
end
switch
(
varargin
{
i
})
case
'field'
if
(
argc
==
i
||
~
strcmp
(
tmparg
,
'real'
)
&&
~
strcmp
(
tmparg
,
'complex'
))
error
(
'field keyword argument is not followed by a valid value: real, complex.'
)
else
field
=
tmparg
;
end
case
'dev'
if
(
argc
==
i
||
~
strcmp
(
tmparg
,
'cpu'
)
&&
~
startsWith
(
tmparg
,
'gpu'
))
error
(
'dev keyword argument is not followed by a valid value: cpu, gpu*.'
)
else
dev
=
tmparg
;
end
case
'class'
if
(
argc
==
i
||
~
strcmp
(
tmparg
,
'double'
)
&&
~
strcmp
(
tmparg
,
'single'
))
error
(
'class keyword argument is not followed by a valid value: single, double.'
)
else
class
=
tmparg
;
end
otherwise
if
((
isstr
(
varargin
{
i
})
||
ischar
(
varargin
{
i
}))
&&
~
strcmp
(
tmparg
,
'cpu'
)
&&
...
~
startsWith
(
tmparg
,
'gpu'
)
&&
~
strcmp
(
tmparg
,
'real'
)
&&
...
~
strcmp
(
tmparg
,
'complex'
)
&&
~
strcmp
(
tmparg
,
'single'
)
&&
~
strcmp
(
tmparg
,
'double'
))
error
([
tmparg
' unrecognized argument'
])
end
end
end
end
if
strcmp
(
field
,
'complex'
)
&&
~
strcmp
(
class
,
'double'
)
error
(
'if field is complex class must be double (complex single is not yet supported)'
)
end
DFT
=
dft
(
n
);
% ignore the bitreversal permutation
B
=
factors
(
DFT
,
1
:
numfactors
(
DFT
)
-
1
);
if
n
==
2
B
=
matfaust
.
Faust
(
B
);
end
RB_factors
=
cell
(
1
,
numfactors
(
B
));
for
k
=
1
:
numfactors
(
B
)
rb
=
factors
(
B
,
k
);
if
~
strcmp
(
field
,
'complex'
)
% real rb
rb
=
real
(
rb
);
[
I
,
J
,
~
]
=
find
(
rb
);
for
i
=
1
:
numel
(
I
)
rb
(
I
(
i
),
J
(
i
))
=
randn
(
1
);
end
else
% complex rb
[
I
,
J
,
~
]
=
find
(
rb
);
for
i
=
1
:
numel
(
I
)
rb
(
I
(
i
),
J
(
i
))
=
randn
(
1
)
+
j
*
randn
(
1
);
end
end
RB_factors
{
1
,
k
}
=
rb
;
end
F
=
matfaust
.
Faust
(
RB_factors
);
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