~ubuntu-branches/debian/squeeze/gmsh/squeeze

« back to all changes in this revision

Viewing changes to contrib/kbipack/kbisnf.m

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme
  • Date: 2009-09-02 18:12:15 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090902181215-yla8zvcas2ucvkm9
[Christophe Prud'homme]
* New upstream release
  + fixed surface mesh orientation bug introduced in 2.4.0;
  + mesh and graphics code refactoring;
  + small usability enhancements and bug fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [U, S, V] = kbisnf(A)
 
2
 
 
3
% [U, S, V] = kbisnf(A)
 
4
%
 
5
% Computes the integer Smith normal form S such that 
 
6
 
7
%   A = U*S*V
 
8
 
9
% Uses external Kannan-Bachem implementation
 
10
 
 
11
%    Copyright (C) 4.11.2003 Saku Suuriniemi TUT/CEM
 
12
%
 
13
%    This program is free software; you can redistribute it and/or modify
 
14
%    it under the terms of the GNU General Public License as published by
 
15
%    the Free Software Foundation; either version 2 of the License, or
 
16
%    any later version.
 
17
%
 
18
%    This program is distributed in the hope that it will be useful,
 
19
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
%    GNU General Public License for more details.
 
22
%
 
23
%    You should have received a copy of the GNU General Public License
 
24
%    along with this program; if not, write to the Free Software
 
25
%    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
26
 
 
27
%   Saku Suuriniemi, TUT/Electromagetics
 
28
%   P.O.Box 692, FIN-33101 Tampere, Finland
 
29
%   saku.suuriniemi@tut.fi
 
30
 
 
31
  [i,j,v] = find(A);
 
32
 
 
33
  fid = fopen('snf_temp.crd', 'w');
 
34
  fprintf(fid, '%g %g %g\n', size(A,1), size(A,2), length(i));
 
35
  if ~isempty(v)
 
36
    fprintf(fid, '%g %g %g\n', [i'; j'; v']);
 
37
  end
 
38
  fclose(fid);
 
39
 
 
40
  system ('./compute_normal_form -S snf_temp.crd');
 
41
 
 
42
  load snf_temp.left;
 
43
  U = zeros(snf_temp(1,1), snf_temp(1,2));
 
44
  for i = 2:size(snf_temp,1)
 
45
     U(snf_temp(i,1), snf_temp(i,2)) = snf_temp(i,3);
 
46
  end
 
47
 
 
48
  load snf_temp.can;
 
49
  S = zeros(snf_temp(1,1), snf_temp(1,2));
 
50
  for i = 2:size(snf_temp,1)
 
51
    S(snf_temp(i,1), snf_temp(i,2)) = snf_temp(i,3);
 
52
  end
 
53
 
 
54
  load snf_temp.right;
 
55
  V = zeros(snf_temp(1,1), snf_temp(1,2));
 
56
  for i = 2:size(snf_temp,1)
 
57
    V(snf_temp(i,1), snf_temp(i,2)) = snf_temp(i,3);
 
58
  end