Mentions légales du service

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

Rename nnz() to nnz_sum() (in matlab and py wrappers).

parent 37ee5123
No related branches found
No related tags found
No related merge requests found
...@@ -69,7 +69,7 @@ norm_A = norm(A) % equivalent to norm(A,2); ...@@ -69,7 +69,7 @@ norm_A = norm(A) % equivalent to norm(A,2);
A_full=full(A); A_full=full(A);
% get the number of non-zeros coefficient % get the number of non-zeros coefficient
nz = nnz(A) nz = nnz_sum(A)
% READING coefficient % READING coefficient
coeff=A(3,4) coeff=A(3,4)
......
...@@ -135,7 +135,7 @@ classdef FaustTest < matlab.unittest.TestCase ...@@ -135,7 +135,7 @@ classdef FaustTest < matlab.unittest.TestCase
function testnnz(this) function testnnz(this)
disp('testnnz()') disp('testnnz()')
this.verifyEqual(nnz(this.test_faust), FaustTest.nnzero_count(this.factors)) this.verifyEqual(nnz_sum(this.test_faust), FaustTest.nnzero_count(this.factors))
end end
function testDensity(this) function testDensity(this)
......
...@@ -201,7 +201,7 @@ disp('Ok'); ...@@ -201,7 +201,7 @@ disp('Ok');
disp('TEST NNZ : '); disp('TEST NNZ : ');
nz = nnz(F); nz = nnz_sum(F);
if(expected_nz ~= nz) if(expected_nz ~= nz)
error('nnz : invalid number of nonzeros'); error('nnz : invalid number of nonzeros');
...@@ -214,7 +214,7 @@ expected_nz_2 = 2*dim1-1; ...@@ -214,7 +214,7 @@ expected_nz_2 = 2*dim1-1;
F_nnz = Faust(new_facts); F_nnz = Faust(new_facts);
nz_F = nnz(F_nnz); nz_F = nnz_sum(F_nnz);
if(nz_F ~= expected_nz_2) if(nz_F ~= expected_nz_2)
error('nnz : invalid number of nonzeros'); error('nnz : invalid number of nonzeros');
...@@ -222,7 +222,7 @@ end ...@@ -222,7 +222,7 @@ end
expected_nz_empty_F = 0; expected_nz_empty_F = 0;
nz_empty_F = nnz(empty_F); nz_empty_F = nnz_sum(empty_F);
if(nz_empty_F ~= expected_nz_empty_F) if(nz_empty_F ~= expected_nz_empty_F)
error('nnz : invalid number of nonzeros (empty Faust)'); error('nnz : invalid number of nonzeros (empty Faust)');
......
...@@ -120,7 +120,7 @@ class TestFaustPy(unittest.TestCase): ...@@ -120,7 +120,7 @@ class TestFaustPy(unittest.TestCase):
def testNnz(self): def testNnz(self):
print("testNnz()") print("testNnz()")
ref_nnz = self.faust_nnz() ref_nnz = self.faust_nnz()
self.assertEqual(ref_nnz, self.F.nnz()) self.assertEqual(ref_nnz, self.F.nnz_sum())
def testDensity(self): def testDensity(self):
print("testDensity()") print("testDensity()")
......
...@@ -813,7 +813,7 @@ classdef Faust ...@@ -813,7 +813,7 @@ classdef Faust
%> %>
%> @endcode %> @endcode
%> %>
%> <p>@b See @b also Faust.nnz, Faust.rcg, Faust.size, Faust.get_fact %> <p>@b See @b also Faust.nnz_sum, Faust.rcg, Faust.size, Faust.get_fact
%> %>
%> %>
%====================================================================== %======================================================================
...@@ -924,10 +924,10 @@ classdef Faust ...@@ -924,10 +924,10 @@ classdef Faust
%> %>
%> <p>@b See @b also Faust.rcg, Faust.density. %> <p>@b See @b also Faust.rcg, Faust.density.
%=========================================================================================== %===========================================================================================
function nz=nnz(F) function nz=nnz_sum(F)
%% NNZ Number of nonzero elements in a Faust (overloaded Matlab built-in function). %% NNZ Number of nonzero elements in a Faust (overloaded Matlab built-in function).
% %
% nz = nnz(F) is the number of nonzero elements in the Faust F. % nz = nnz_sum(F) is the number of nonzero elements in the Faust F.
% %
% See also density, rcg. % See also density, rcg.
if (F.isReal) if (F.isReal)
...@@ -954,7 +954,7 @@ classdef Faust ...@@ -954,7 +954,7 @@ classdef Faust
%> dens = density(F) %> dens = density(F)
%> @endcode %> @endcode
%> %>
%> <p/>@b See @b also Faust.nnz, Faust.rcg %> <p/>@b See @b also Faust.nnz_sum, Faust.rcg
%====================================================================== %======================================================================
function dens=density(F) function dens=density(F)
%% DENSITY Density of the Faust. %% DENSITY Density of the Faust.
...@@ -965,11 +965,11 @@ classdef Faust ...@@ -965,11 +965,11 @@ classdef Faust
% In some degenerated case, dens can be greater than 1. % In some degenerated case, dens can be greater than 1.
% If the Faust is empty, return -1. % If the Faust is empty, return -1.
% %
% See also rcg, nnz. % See also rcg, nnz_sum.
prod_dim=prod(size(F)); prod_dim=prod(size(F));
if (prod_dim ~= 0) if (prod_dim ~= 0)
dens=nnz(F)/prod_dim; dens=nnz_sum(F)/prod_dim;
else else
dens = -1; dens = -1;
end end
...@@ -988,7 +988,7 @@ classdef Faust ...@@ -988,7 +988,7 @@ classdef Faust
%> %>
%> @retval speed_up = the RCG value (real). If the density is zero it will be Inf. If the density is negative it will be -1. %> @retval speed_up = the RCG value (real). If the density is zero it will be Inf. If the density is negative it will be -1.
%> %>
%> <p>@b See @b also Faust.density, Faust.nnz. %> <p>@b See @b also Faust.density, Faust.nnz_sum.
%=========================================================================================== %===========================================================================================
function speed_up=rcg(F) function speed_up=rcg(F)
%% RCG Relative Complexity Gain (inverse of the density) %% RCG Relative Complexity Gain (inverse of the density)
...@@ -998,7 +998,7 @@ classdef Faust ...@@ -998,7 +998,7 @@ classdef Faust
% both for storage and multiplication computation time between the Faust and its full storage % both for storage and multiplication computation time between the Faust and its full storage
% equivalent full(F)). % equivalent full(F)).
% %
% See also density, nnz. % See also density, nnz_sum.
dens=density(F); dens=density(F);
if (dens > 0) if (dens > 0)
......
...@@ -310,7 +310,7 @@ class Faust: ...@@ -310,7 +310,7 @@ class Faust:
>>> 1, 2, 50, 100, .5) >>> 1, 2, 50, 100, .5)
>>> F.display() >>> F.display()
<b/>See also Faust.nnz, Faust.rcg, Faust.size, Faust.get_factor, <b/>See also Faust.nnz_sum, Faust.rcg, Faust.size, Faust.get_factor,
Faust.get_nb_factors Faust.get_nb_factors
""" """
...@@ -423,7 +423,7 @@ class Faust: ...@@ -423,7 +423,7 @@ class Faust:
submatrix = submatrix[keyRow, :] submatrix = submatrix[keyRow, :]
return submatrix return submatrix
def nnz(F): def nnz_sum(F):
""" """
Gives the total number of non-zero elements in F's factors. Gives the total number of non-zero elements in F's factors.
...@@ -459,9 +459,9 @@ class Faust: ...@@ -459,9 +459,9 @@ class Faust:
>>> 5, 50, 100, .5) >>> 5, 50, 100, .5)
>>> dens = F.density() >>> dens = F.density()
<b/> See also Faust.nnz, Faust.rcg <b/> See also Faust.nnz_sum, Faust.rcg
""" """
return float(F.nnz())/(F.get_nb_cols()*F.get_nb_rows()) return float(F.nnz_sum())/(F.get_nb_cols()*F.get_nb_rows())
def rcg(F): def rcg(F):
""" """
...@@ -482,7 +482,7 @@ class Faust: ...@@ -482,7 +482,7 @@ class Faust:
Examples: Examples:
>>> F.rcg() >>> F.rcg()
<b/> See also: Faust.density, Faust.nnz. <b/> See also: Faust.density, Faust.nnz_sum.
""" """
d = F.density() d = F.density()
if(d > 0): if(d > 0):
......
...@@ -107,7 +107,7 @@ for i in range(nb_mult): ...@@ -107,7 +107,7 @@ for i in range(nb_mult):
print("multiplication SPEED-UP using Faust") print("multiplication SPEED-UP using Faust")
print("Faust is "+str(t_dense/t_faust)+" faster than a full matrix") print("Faust is "+str(t_dense/t_faust)+" faster than a full matrix")
print("Faust nnz: "+str(A.nnz())) print("Faust nnz: "+str(A.nnz_sum()))
print("Faust density: "+str(A.density())) print("Faust density: "+str(A.density()))
print("Faust RCG: "+str(A.rcg())) print("Faust RCG: "+str(A.rcg()))
print("Faust norm: "+str(A.norm())) print("Faust norm: "+str(A.norm()))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment