Mentions légales du service

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

Secure normlin/normcol norm parameter to be >= 0 (otherwise an error is raised).

parent 76db5504
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,9 @@ classdef normcol < matfaust.proj.proj_gen
%===============================================
function proj = normcol(shape, normval)%, varargin)
import matfaust.factparams.ConstraintReal
if(normval < 0)
error('A norm can''t be negative')
end
proj.constraint = ConstraintReal('normcol', shape(1), shape(2), normval)%, varargin{:});
end
end
......
......@@ -17,6 +17,9 @@ classdef normlin < matfaust.proj.proj_gen
%===============================================
function proj = normlin(shape, normval, varargin)
import matfaust.factparams.ConstraintReal
if(normval < 0)
error('A norm can''t be negative')
end
proj.constraint = ConstraintReal('normlin', shape(1), shape(2), normval, varargin{:});
end
end
......
......@@ -372,6 +372,8 @@ class normcol(proj_gen):
>>> norm(p(M)[:,0], 2)
0.01
"""
if(s < 0):
raise ValueError('A norm can\'t be negative')
normalized=False
pos=False
self.constraint = ConstraintReal('normcol', shape[0], shape[1], s, normalized, pos)
......@@ -404,6 +406,8 @@ class normlin(proj_gen):
pos: True to skip negative values (replaced by zero) of the matrix to project.
"""
if(s < 0):
raise ValueError('A norm can\'t be negative')
normalized=False
pos=False
self.constraint = ConstraintReal('normlin', shape[0], shape[1], s, normalized, pos)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment