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
397ba846
Commit
397ba846
authored
6 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Update pyfaust/matfaust API doc, in particular for Faust addition and substraction.
parent
36957e8d
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
wrapper/matlab/+matfaust/@Faust/Faust.m
+38
-3
38 additions, 3 deletions
wrapper/matlab/+matfaust/@Faust/Faust.m
wrapper/python/pyfaust.py
+41
-8
41 additions, 8 deletions
wrapper/python/pyfaust.py
with
79 additions
and
11 deletions
wrapper/matlab/+matfaust/@Faust/Faust.m
+
38
−
3
View file @
397ba846
...
...
@@ -68,8 +68,6 @@
%> - compute the real and imaginary parts of a Faust,
%> - perform elementwise operations between two Fausts (e.g. elementwise
%> multiplication).
%> In particular, the addition F+G is undefined for Faust objects (so
%> far).
%> - reshape,
%> - invert.
%>
...
...
@@ -248,6 +246,24 @@ classdef Faust
end
%======================================================================
%> @brief Plus
%>
%===
%> This function overloads a Matlab built-in function.
%>
%>
%> @b Usage
%>
%> @b plus(F,G) or F+G adds two Faust together, sizes must be compatible.<br/>
%> @b plus(F,A) or F+A adds a Faust and a matrix A, sizes must be compatible.<br/>
%> @b plus(F,s) or F+s, with s being a scalar, such that full(F+s) == full(F)+s.<br/>
%>
%> @param F (first arg.) The Faust object.
%> @param G, A, s,… (2nd to n-th args) The variables to add to F; Fausts, matrices or scalars.
%>
%> @retval S: the sum as a Faust object.
%>
%> <p>@b See @b also Faust.minus
%======================================================================
function
F
=
plus
(
varargin
)
import
matfaust
.
Faust
...
...
@@ -286,6 +302,24 @@ classdef Faust
end
%======================================================================
%> @brief Minus
%>
%===
%> This function overloads a Matlab built-in function.
%>
%>
%> @b Usage
%>
%> @b minus(F,G) or F-G substracts the Faust G from F, sizes must be compatible.<br/>
%> @b minus(F,A) or F-A substracts a matrix A from F, sizes must be compatible.<br/>
%> @b minus(F,s) or F-s substracts a scalar s from F, such that full(F-s) == full(F)-s.<br/>
%>
%> @param F (first arg.) The Faust object.
%> @param G, A, s,… (2nd to n-th args) The variables to substract from F; Fausts, matrices or scalars.
%>
%> @retval M: the difference as a Faust object.
%>
%> <p>@b See @b also Faust.plus
%======================================================================
function
M
=
minus
(
varargin
)
M
=
varargin
{
1
}
...
...
@@ -300,7 +334,7 @@ classdef Faust
%===
%> @b Usage
%>
%> G = F/s is the division of the Faust F by the scalar s
.
<br/>
%> G = F/s is the division of the Faust F by the scalar s
, such that full(F)/s == full(F/s)
<br/>
%> G = MRDIVIDE(F,s) is called for the syntax 'F / s' when s is a scalar.
%>
%> @param F The Faust object to divide.
...
...
@@ -308,6 +342,7 @@ classdef Faust
%>
%> @retval G: the division result as a Faust object.
%>
%> <p>@b See @b also Faust.mtimes
%======================================================================
function
G
=
mrdivide
(
F
,
s
)
if
(
~
isscalar
(
s
))
...
...
This diff is collapsed.
Click to expand it.
wrapper/python/pyfaust.py
+
41
−
8
View file @
397ba846
...
...
@@ -84,9 +84,7 @@ class Faust:
Other notable limitations are that one cannot:
- compute the real and imaginary parts of a Faust,
- perform elementwise operations between two Fausts (e.g. elementwise
multiplication).
In particular, the addition F+G is undefined for Faust objects (so
far).
multiplication),
- reshape.
Primarily for convenience and test purposes, a Faust can be converted into
...
...
@@ -415,7 +413,21 @@ class Faust:
print
(
F
.
__repr__
())
#F.m_faust.display()
def
__add__
(
F
,
*
args
):
def
__add__
(
F
,
*
args
):
"""
Sums F to one or a sequence of variables. Faust objects, arrays or scalars.
This method overloads the Python function/operator +.
Args:
*args: the list of variables to sum all together with F. These can
be: Faust objects, arrays (and scipy.sparse.csr_matrix) or scalars.
Faust and arrays/matrices must be of compatible size.
Returns: the sum as a Faust object.
<b/>See also Faust.__sub__
"""
for
i
in
range
(
0
,
len
(
args
)):
G
=
args
[
i
]
if
(
isinstance
(
G
,
Faust
)):
...
...
@@ -445,6 +457,21 @@ class Faust:
return
F
def
__sub__
(
F
,
*
args
):
"""
Substracts from F one or a sequence of variables. Faust objects, arrays or scalars.
This method overloads the Python function/operator -.
Args:
*args: the list of variables to compute the difference with F. These can
be: Faust objects, arrays (and scipy.sparse.csr_matrix) or scalars.
Faust and arrays/matrices must be of compatible size.
Returns: the difference as a Faust object.
<b/>See also Faust.__add__
"""
nargs
=
[]
for
arg
in
args
:
nargs
+=
[
arg
*-
1
]
...
...
@@ -454,11 +481,17 @@ class Faust:
"""
Divides F by the scalar s.
This method overloads the Python function/operator `/
'
(whether s is a
float or an integer).
Args:
- F: the Faust object.
- s: the scalar to divide the Faust object with.
F: the Faust object.
s: the scalar to divide the Faust object with.
Returns:
the division result as a Faust object.
Returns: the division result as a Faust object.
<b/> See also Faust.__mul__
"""
if
(
isinstance
(
s
,
float
)
or
isinstance
(
s
,
np
.
complex
)
or
isinstance
(
s
,
int
)):
...
...
@@ -539,7 +572,7 @@ class Faust:
>>>
# H is a Faust because F and G are
>>>
F_times_two
=
F
*
2
<b/>See also Faust.__init__, Faust.rcg
<b/>See also Faust.__init__, Faust.rcg
, Faust.__mul__
"""
if
(
isinstance
(
A
,
Faust
)):
if
(
F
.
shape
[
1
]
!=
A
.
shape
[
0
]):
raise
ValueError
(
"
The dimensions of
"
...
...
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