~logan/ubuntu/trusty/suitesparse/4.2.1-3ubuntu1

« back to all changes in this revision

Viewing changes to CXSparse_newfiles/MATLAB/Test/test14.m

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2007-05-29 09:36:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529093629-zowquo0b7slkk6nc
Tags: 3.0.0-2
* suitesparse builds properly twice in a row
* Bug fix: "suitesparse - FTBFS: Broken build depens: libgfortran1-dev",
  thanks to Bastian Blank (Closes: #426349).
* Bug fix: "suitesparse_3.0.0-1: FTBFS: build-depends on
  libgfortran1-dev", thanks to Steve Langasek (Closes: #426354).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function test14
 
2
%TEST14 test cs_droptol
 
3
%
 
4
% Example:
 
5
%   test14
 
6
% See also: testall
 
7
 
 
8
%   Copyright 2006-2007, Timothy A. Davis.
 
9
%   http://www.cise.ufl.edu/research/sparse
 
10
 
 
11
 
 
12
rand ('state', 0) ;
 
13
 
 
14
for trial = 1:100
 
15
    m = fix (100 * rand (1)) ;
 
16
    n = fix (100 * rand (1)) ;
 
17
    d = 0.1*rand (1) ;
 
18
    A = sprandn (m,n,d) ;
 
19
    [i j x] = find (A) ;
 
20
    A = sparse (i,j,2*x-1) ;
 
21
    fprintf ('test14 m %3d n %3d nz %d\n', m, n, nnz (A)) ;
 
22
 
 
23
    for cmplex = 0:1
 
24
 
 
25
        if (cmplex)
 
26
            A = A + 1i * sparse (i,j,2*rand(size(x))-1) ;
 
27
        end
 
28
 
 
29
        % using CSparse
 
30
        tol = 0.5 ;
 
31
        B = cs_droptol (A, tol) ;
 
32
 
 
33
        % using MATLAB
 
34
        C = A .* (abs (A) > tol) ;
 
35
    %    [m n] = size (A) ;
 
36
    %    s = abs (A) > tol ;
 
37
    %    [i j] = find (s) ;
 
38
    %    x = A (find (s)) ;
 
39
    %    A = sparse (i, j, x, m, n) ;
 
40
 
 
41
        if (norm (C-B,1) > 0)
 
42
            error ('!') ;
 
43
        end
 
44
    end
 
45
end