annotate src/DLD-FUNCTIONS/kron.cc @ 10154:40dfc0c99116

DLD-FUNCTIONS/*.cc: untabify
author John W. Eaton <jwe@octave.org>
date Wed, 20 Jan 2010 17:33:41 -0500
parents 923c7cb7f13f
children 12884915a8e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
1 /*
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
2
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 7789
diff changeset
3 Copyright (C) 2002, 2005, 2006, 2007, 2008 John W. Eaton
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
4
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
6
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6678
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6678
diff changeset
10 option) any later version.
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
11
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
15 for more details.
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
16
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6678
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6678
diff changeset
19 <http://www.gnu.org/licenses/>.
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
20
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
21 */
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
22
3911
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3910
diff changeset
23 // Author: Paul Kienzle <pkienzle@users.sf.net>
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3910
diff changeset
24
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
26 #include <config.h>
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
27 #endif
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
28
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
29 #include "dMatrix.h"
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
30 #include "CMatrix.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3911
diff changeset
31 #include "quit.h"
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
32
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
33 #include "defun-dld.h"
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
34 #include "error.h"
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
35 #include "oct-obj.h"
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
36
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
37 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
38 extern void
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
39 kron (const Array2<double>&, const Array2<double>&, Array2<double>&);
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
40
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
41 extern void
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
42 kron (const Array2<Complex>&, const Array2<Complex>&, Array2<Complex>&);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
43
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
44 extern void
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
45 kron (const Array2<float>&, const Array2<float>&, Array2<float>&);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
46
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
47 extern void
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
48 kron (const Array2<FlaotComplex>&, const Array2<FloatComplex>&,
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
49 Array2<FloatComplex>&);
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
50 #endif
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
51
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
52 template <class T>
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
53 void
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
54 kron (const Array2<T>& A, const Array2<T>& B, Array2<T>& C)
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
55 {
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
56 C.resize (A.rows () * B.rows (), A.columns () * B.columns ());
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
57
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4153
diff changeset
58 octave_idx_type Ac, Ar, Cc, Cr;
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
59
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
60 for (Ac = Cc = 0; Ac < A.columns (); Ac++, Cc += B.columns ())
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
61 for (Ar = Cr = 0; Ar < A.rows (); Ar++, Cr += B.rows ())
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
62 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
63 const T v = A (Ar, Ac);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
64 for (octave_idx_type Bc = 0; Bc < B.columns (); Bc++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
65 for (octave_idx_type Br = 0; Br < B.rows (); Br++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
66 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
67 OCTAVE_QUIT;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
68 C.xelem (Cr+Br, Cc+Bc) = v * B.elem (Br, Bc);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
69 }
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
70 }
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
71 }
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
72
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
73 template void
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
74 kron (const Array2<double>&, const Array2<double>&, Array2<double>&);
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
75
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
76 template void
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
77 kron (const Array2<Complex>&, const Array2<Complex>&, Array2<Complex>&);
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
78
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
79 template void
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
80 kron (const Array2<float>&, const Array2<float>&, Array2<float>&);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
81
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
82 template void
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
83 kron (const Array2<FloatComplex>&, const Array2<FloatComplex>&,
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
84 Array2<FloatComplex>&);
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
85
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
86 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
87 extern void
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
88 kron (const Sparse<double>&, const Sparse<double>&, Sparse<double>&);
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
89
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
90 extern void
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
91 kron (const Sparse<Complex>&, const Sparse<Complex>&, Sparse<Complex>&);
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
92 #endif
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
93
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
94 template <class T>
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
95 void
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
96 kron (const Sparse<T>& A, const Sparse<T>& B, Sparse<T>& C)
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
97 {
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
98 octave_idx_type idx = 0;
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
99 C = Sparse<T> (A.rows () * B.rows (), A.columns () * B.columns (),
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
100 A.nzmax () * B.nzmax ());
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
101
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
102 C.cidx (0) = 0;
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
103
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
104 for (octave_idx_type Aj = 0; Aj < A.columns (); Aj++)
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
105 for (octave_idx_type Bj = 0; Bj < B.columns (); Bj++)
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
106 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
107 for (octave_idx_type Ai = A.cidx (Aj); Ai < A.cidx (Aj+1); Ai++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
108 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
109 octave_idx_type Ci = A.ridx(Ai) * B.rows ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
110 const T v = A.data (Ai);
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
111
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
112 for (octave_idx_type Bi = B.cidx (Bj); Bi < B.cidx (Bj+1); Bi++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
113 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
114 OCTAVE_QUIT;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
115 C.data (idx) = v * B.data (Bi);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
116 C.ridx (idx++) = Ci + B.ridx (Bi);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
117 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
118 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
119 C.cidx (Aj * B.columns () + Bj + 1) = idx;
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
120 }
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
121 }
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
122
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
123 template void
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
124 kron (const Sparse<double>&, const Sparse<double>&, Sparse<double>&);
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
125
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
126 template void
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
127 kron (const Sparse<Complex>&, const Sparse<Complex>&, Sparse<Complex>&);
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
128
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
129
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
130 DEFUN_DLD (kron, args, nargout, "-*- texinfo -*-\n\
6678
49724abe1236 [project @ 2007-05-31 19:44:45 by jwe]
jwe
parents: 5823
diff changeset
131 @deftypefn {Loadable Function} {} kron (@var{a}, @var{b})\n\
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
132 Form the kronecker product of two matrices, defined block by block as\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
133 \n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
134 @example\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
135 x = [a(i, j) b]\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
136 @end example\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
137 \n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
138 For example,\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
139 \n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
140 @example\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
141 @group\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
142 kron (1:4, ones (3, 1))\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
143 @result{} 1 2 3 4\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
144 1 2 3 4\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
145 1 2 3 4\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
146 @end group\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
147 @end example\n\
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
148 @end deftypefn")
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
149 {
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
150 octave_value_list retval;
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
151
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
152 int nargin = args.length ();
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
153
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
154 if (nargin != 2 || nargout > 1)
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
155 {
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5307
diff changeset
156 print_usage ();
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
157 }
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
158 else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
159 {
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
160 if (args(0).is_complex_type () || args(1).is_complex_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
161 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
162 SparseComplexMatrix a (args(0).sparse_complex_matrix_value());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
163 SparseComplexMatrix b (args(1).sparse_complex_matrix_value());
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
164
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
165 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
166 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
167 SparseComplexMatrix c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
168 kron (a, b, c);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
169 retval(0) = c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
170 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
171 }
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
172 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
173 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
174 SparseMatrix a (args(0).sparse_matrix_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
175 SparseMatrix b (args(1).sparse_matrix_value ());
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
176
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
177 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
178 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
179 SparseMatrix c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
180 kron (a, b, c);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
181 retval (0) = c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
182 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
183 }
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
184 }
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
185 else
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
186 {
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
187 if (args(0).is_single_type () || args(1).is_single_type ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
188 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
189 if (args(0).is_complex_type () || args(1).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
190 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
191 FloatComplexMatrix a (args(0).float_complex_matrix_value());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
192 FloatComplexMatrix b (args(1).float_complex_matrix_value());
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
193
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
194 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
195 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
196 FloatComplexMatrix c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
197 kron (a, b, c);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
198 retval(0) = c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
199 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
200 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
201 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
202 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
203 FloatMatrix a (args(0).float_matrix_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
204 FloatMatrix b (args(1).float_matrix_value ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
205
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
206 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
207 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
208 FloatMatrix c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
209 kron (a, b, c);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
210 retval (0) = c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
211 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
212 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
213 }
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
214 else
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
215 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
216 if (args(0).is_complex_type () || args(1).is_complex_type ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
217 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
218 ComplexMatrix a (args(0).complex_matrix_value());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
219 ComplexMatrix b (args(1).complex_matrix_value());
7455
fe332ce262b5 eliminate spkron.cc; dispatch in kron
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
220
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
221 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
222 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
223 ComplexMatrix c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
224 kron (a, b, c);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
225 retval(0) = c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
226 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
227 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
228 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
229 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
230 Matrix a (args(0).matrix_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
231 Matrix b (args(1).matrix_value ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7455
diff changeset
232
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
233 if (! error_state)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
234 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
235 Matrix c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
236 kron (a, b, c);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
237 retval (0) = c;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
238 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
239 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9209
diff changeset
240 }
3910
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
241 }
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
242
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
243 return retval;
79a90a0f0eff [project @ 2002-04-25 05:36:52 by jwe]
jwe
parents:
diff changeset
244 }