Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a0f7bf43 authored by hhakim's avatar hhakim
Browse files

Implement the commutativity in the mul. of a Faust by a scalar in matfaust.

Adding a few examples in the doc.
parent bb0428fe
No related branches found
No related tags found
No related merge requests found
...@@ -216,8 +216,10 @@ classdef Faust ...@@ -216,8 +216,10 @@ classdef Faust
%> %>
%> @b Usage %> @b Usage
%> %>
%> &nbsp;&nbsp;&nbsp; @b B = mtimes(F, A)<br/> %> &nbsp;&nbsp;&nbsp; @b G = mtimes(F, A)<br/>
%> &nbsp;&nbsp;&nbsp; @b B = F*A %> &nbsp;&nbsp;&nbsp; @b G = F*A<br/>
%> &nbsp;&nbsp;&nbsp; @b G = F*s with s a scalar.<br/>
%> &nbsp;&nbsp;&nbsp; @b G = s*F with s a scalar.
%> %>
%> %>
%> @b NOTE: The primary goal of this function is to implement “fast” multiplication by a %> @b NOTE: The primary goal of this function is to implement “fast” multiplication by a
...@@ -230,31 +232,38 @@ classdef Faust ...@@ -230,31 +232,38 @@ classdef Faust
%> @param F the Faust object. %> @param F the Faust object.
%> @param A The dense matrix to multiply or a Faust object. %> @param A The dense matrix to multiply or a Faust object.
%> %>
%> @retval B The multiplication result (a dense matrix or a Faust object depending on what A is). %> @retval G The multiplication result (a dense matrix or a Faust object depending on what A is).
%> %>
%> @b Example %> @b Example
%> @code %> @code
%> import matfaust.FaustFactory %> import matfaust.FaustFactory
%> F = FaustFactory.rand([2, 5], [50, 100], .5) %> F = FaustFactory.rand([2, 5], [50, 100], .5)
%> A = rand(size(F,2), 50) %> A = rand(size(F,2), 50)
%> B = F*A %> G = F*A
%> % is equivalent to B = mtimes(F, A) %> % is equivalent to G = mtimes(F, A)
%> G = FaustFactory.rand(5,size(F, 2)) %> G = FaustFactory.rand(5,size(F, 2))
%> H = F*G %> H = F*G
%> % H is a Faust because F and G are %> % H is a Faust because F and G are
%> Fs = F*2
%> sF = 2*F
%> % sF == Fs, i.e. the Faust F times 2.
%> @endcode %> @endcode
%> %>
%> <p>@b See @b also Faust.Faust, Faust.rcg. %> <p>@b See @b also Faust.Faust, Faust.rcg.
%> %>
%====================================================================== %======================================================================
function B = mtimes(F,A) function G = mtimes(F,A)
%% MTIMES * Faust Multiplication (overloaded Matlab built-in function). %% MTIMES * Faust Multiplication (overloaded Matlab built-in function).
% %
% B=mtimes(F,A) is called for syntax 'B=F*A', when F is a Faust matrix and A a full % G=mtimes(F,A) is called for syntax 'G=F*A', when F is a Faust matrix and A a full
% storage matrix, B is also a full matrix storage. % storage matrix, G is also a full matrix storage.
% %
% See also mtimes_trans % See also mtimes_trans
B = mtimes_trans(F, A, 0); if(isa(A, 'matfaust.Faust') && isscalar(F))
G = mtimes_trans(A,F, 0);
else
G = mtimes_trans(F, A, 0);
end
end end
......
...@@ -405,7 +405,7 @@ mxArray* transformFact2FullMxArray(faust_unsigned_int id, Faust::TransformHelper ...@@ -405,7 +405,7 @@ mxArray* transformFact2FullMxArray(faust_unsigned_int id, Faust::TransformHelper
template<class FPP> template<class FPP>
void mxArray2Scalar(const mxArray* scalar, typename std::enable_if<std::is_floating_point<FPP>::value, FPP>::type* out) void mxArray2Scalar(const mxArray* scalar, typename std::enable_if<std::is_floating_point<FPP>::value, FPP>::type* out)
{ {
cout << "mxArray2Scalar() FPP real" << endl; // cout << "mxArray2Scalar() FPP real" << endl;
*out = mxGetScalar(scalar); *out = mxGetScalar(scalar);
} }
...@@ -418,7 +418,7 @@ void mxArray2Scalar(const mxArray* scalar, complex<FPP>* out) ...@@ -418,7 +418,7 @@ void mxArray2Scalar(const mxArray* scalar, complex<FPP>* out)
if(mxIsComplex(scalar)) if(mxIsComplex(scalar))
{ {
im_ptr = (FPP*) mxGetPi(scalar); im_ptr = (FPP*) mxGetPi(scalar);
cout << "im_ptr[0]: " << im_ptr[0] << endl; // cout << "im_ptr[0]: " << im_ptr[0] << endl;
cplx = complex<FPP>(real_part, im_ptr[0]); cplx = complex<FPP>(real_part, im_ptr[0]);
} }
else else
......
...@@ -423,6 +423,7 @@ class Faust: ...@@ -423,6 +423,7 @@ class Faust:
>>> G = FaustFactory.rand(5, F.shape[1]) >>> G = FaustFactory.rand(5, F.shape[1])
>>> H = F*G >>> H = F*G
>>> # H is a Faust because F and G are >>> # H is a Faust because F and G are
>>> F_times_two = 2*F
<b/>See also Faust.__init__, Faust.rcg <b/>See also Faust.__init__, Faust.rcg
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment