Mentions légales du service

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

Prevent explicitly complex matrix factorization.

It's not yet implemented in C++ core, so the code raise an exception to be explicit (pyfaust and matfaust).
parent f1660ddb
Branches
Tags
No related merge requests found
......@@ -63,6 +63,7 @@ classdef FaustFactory
function F = fact_palm4msa(M, p)
import matfaust.Faust
mex_constraints = cell(1, length(p.constraints));
matfaust.FaustFactory.check_fact_mat('FaustFactory.fact_palm4msa', M)
for i=1:length(p.constraints)
cur_cell = cell(1, 4);
cur_cell{1} = p.constraints{i}.name.conv2str();
......@@ -122,6 +123,7 @@ classdef FaustFactory
function F = fact_hierarchical(M, p)
import matfaust.Faust
mex_constraints = cell(2, p.num_facts-1);
matfaust.FaustFactory.check_fact_mat('FaustFactory.fact_hierarchical', M)
%mex_fact_constraints = cell(1, p.num_facts-1)
for i=1:p.num_facts-1
cur_cell = cell(1, 4);
......@@ -320,4 +322,17 @@ classdef FaustFactory
end
end
methods(Access = private, Static)
function check_fact_mat(funcname, M)
if(~ ismatrix(M) || isscalar(M))
error([funcname,'() 1st argument (M) must be a matrix.'])
end
if(~ isnumeric(M))
error([funcname, '() 1st argument (M) must be real or complex.'])
end
if(~ isreal(M))
error([funcname, '() doesn''t yet support complex matrix factorization.'])
end
end
end
end
......@@ -903,6 +903,7 @@ class FaustFactory:
"""
if(not isinstance(p, ParamsPalm4MSA)):
raise ValueError("p must be a ParamsPalm4MSA object.")
FaustFactory._check_fact_mat('FaustFactory.fact_palm4msa()', M)
return Faust(core_obj=FaustCorePy.FaustFact.fact_palm4MSA(M, p))
@staticmethod
......@@ -955,6 +956,7 @@ class FaustFactory:
"""
if(not isinstance(p, ParamsHierarchicalFact)):
raise ValueError("p must be a ParamsPalm4MSA object.")
FaustFactory._check_fact_mat('FaustFactory.fact_hierarchical()', M)
return Faust(core_obj=FaustCorePy.FaustFact.fact_hierarchical(M, p))
@staticmethod
......@@ -1051,6 +1053,20 @@ class FaustFactory:
min_dim_size, max_dim_size, density))
return rF
@staticmethod
def _check_fact_mat(funcname, M):
if(not isinstance(M, np.ndarray)):
raise Exception(funcname+" 1st argument must be a numpy ndarray.")
if(not isinstance(M[0,0], np.complex) and not isinstance(M[0,0],
np.float)):
raise Exception(funcname+" 1st argument must be a float or complex "
"ndarray.")
if(isinstance(M[0,0], np.complex)):
raise Exception(funcname+" doesn't yet support complex matrix "
"factorization.")
class ParamsFact(object):
def __init__(self, num_facts, is_update_way_R2L, init_lambda,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment