annotate src/xdiv.cc @ 7017:a1dbe9d80eee

[project @ 2007-10-12 21:27:11 by jwe]
author jwe
date Fri, 12 Oct 2007 21:27:37 +0000
parents 93c65f2a5668
children 82be108cc558
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2003,
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 2005, 2006, 2007 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
9 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: 5785
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5785
diff changeset
11 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
18 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: 5785
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5785
diff changeset
20 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
23
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 164
diff changeset
24 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1009
diff changeset
25 #include <config.h>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
27
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
28 #include <cassert>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
29
4669
334a27c8f453 [project @ 2003-11-26 07:02:42 by jwe]
jwe
parents: 4543
diff changeset
30 #include "Array-util.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
31 #include "CMatrix.h"
453
393e95f46b51 [project @ 1994-06-06 00:05:20 by jwe]
jwe
parents: 240
diff changeset
32 #include "dMatrix.h"
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
33 #include "CNDArray.h"
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
34 #include "dNDArray.h"
1651
e846e361a265 [project @ 1995-12-20 06:59:12 by jwe]
jwe
parents: 1488
diff changeset
35 #include "oct-cmplx.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
36 #include "quit.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
37
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
38 #include "error.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
39 #include "xdiv.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
40
3480
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
41 static inline bool
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
42 result_ok (octave_idx_type info)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
43 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
44 assert (info != -1);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
45
3480
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
46 return (info != -2);
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
47 }
932
1c9812d0cf59 [project @ 1994-11-16 15:40:32 by jwe]
jwe
parents: 931
diff changeset
48
3480
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
49 static void
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
50 solve_singularity_warning (double rcond)
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
51 {
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
52 warning ("matrix singular to machine precision, rcond = %g", rcond);
3719
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3480
diff changeset
53 warning ("attempting to find minimum norm solution");
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
54 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
55
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
56 template <class T1, class T2>
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
57 bool
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
58 mx_leftdiv_conform (const T1& a, const T2& b)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
59 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
60 octave_idx_type a_nr = a.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
61 octave_idx_type b_nr = b.rows ();
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
62
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
63 if (a_nr != b_nr)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
64 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
65 octave_idx_type a_nc = a.cols ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
66 octave_idx_type b_nc = b.cols ();
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
67
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
68 gripe_nonconformant ("operator \\", a_nr, a_nc, b_nr, b_nc);
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
69 return false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
70 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
71
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
72 return true;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
73 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
74
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
75 #define INSTANTIATE_MX_LEFTDIV_CONFORM(T1, T2) \
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
76 template bool mx_leftdiv_conform (const T1&, const T2&)
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
77
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
78 INSTANTIATE_MX_LEFTDIV_CONFORM (Matrix, Matrix);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
79 INSTANTIATE_MX_LEFTDIV_CONFORM (Matrix, ComplexMatrix);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
80 INSTANTIATE_MX_LEFTDIV_CONFORM (ComplexMatrix, Matrix);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
81 INSTANTIATE_MX_LEFTDIV_CONFORM (ComplexMatrix, ComplexMatrix);
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
82
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
83 template <class T1, class T2>
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
84 bool
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
85 mx_div_conform (const T1& a, const T2& b)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
86 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
87 octave_idx_type a_nc = a.cols ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
88 octave_idx_type b_nc = b.cols ();
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
89
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
90 if (a_nc != b_nc)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
91 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
92 octave_idx_type a_nr = a.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
93 octave_idx_type b_nr = b.rows ();
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
94
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
95 gripe_nonconformant ("operator /", a_nr, a_nc, b_nr, b_nc);
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
96 return false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
97 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
98
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
99 return true;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
100 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
101
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
102 #define INSTANTIATE_MX_DIV_CONFORM(T1, T2) \
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
103 template bool mx_div_conform (const T1&, const T2&)
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
104
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
105 INSTANTIATE_MX_DIV_CONFORM (Matrix, Matrix);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
106 INSTANTIATE_MX_DIV_CONFORM (Matrix, ComplexMatrix);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
107 INSTANTIATE_MX_DIV_CONFORM (ComplexMatrix, Matrix);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
108 INSTANTIATE_MX_DIV_CONFORM (ComplexMatrix, ComplexMatrix);
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
109
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
110 // Right division functions.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
111 //
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
112 // op2 / op1: m cm
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
113 // +-- +---+----+
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
114 // matrix | 1 | 3 |
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
115 // +---+----+
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
116 // complex_matrix | 2 | 4 |
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
117 // +---+----+
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
118
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
119 // -*- 1 -*-
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
120 Matrix
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
121 xdiv (const Matrix& a, const Matrix& b, MatrixType &typ)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
122 {
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
123 if (! mx_div_conform (a, b))
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
124 return Matrix ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
125
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
126 Matrix atmp = a.transpose ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
127 Matrix btmp = b.transpose ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
128 MatrixType btyp = typ.transpose ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
129
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
130 octave_idx_type info;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
131 double rcond = 0.0;
3480
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
132
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
133 Matrix result
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
134 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
135
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
136 typ = btyp.transpose ();
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
137 return result.transpose ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
138 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
139
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
140 // -*- 2 -*-
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
141 ComplexMatrix
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
142 xdiv (const Matrix& a, const ComplexMatrix& b, MatrixType &typ)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
143 {
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
144 if (! mx_div_conform (a, b))
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
145 return ComplexMatrix ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
146
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
147 Matrix atmp = a.transpose ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
148 ComplexMatrix btmp = b.hermitian ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
149 MatrixType btyp = typ.transpose ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
150
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
151 octave_idx_type info;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
152 double rcond = 0.0;
3480
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
153
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
154 ComplexMatrix result
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
155 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
156
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
157 typ = btyp.transpose ();
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
158 return result.hermitian ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
159 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
160
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
161 // -*- 3 -*-
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
162 ComplexMatrix
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
163 xdiv (const ComplexMatrix& a, const Matrix& b, MatrixType &typ)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
164 {
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
165 if (! mx_div_conform (a, b))
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
166 return ComplexMatrix ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
167
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
168 ComplexMatrix atmp = a.hermitian ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
169 Matrix btmp = b.transpose ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
170 MatrixType btyp = typ.transpose ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
171
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
172 octave_idx_type info;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
173 double rcond = 0.0;
3480
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
174
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
175 ComplexMatrix result
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
176 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
177
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
178 typ = btyp.transpose ();
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
179 return result.hermitian ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
180 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
181
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
182 // -*- 4 -*-
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
183 ComplexMatrix
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
184 xdiv (const ComplexMatrix& a, const ComplexMatrix& b, MatrixType &typ)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
185 {
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
186 if (! mx_div_conform (a, b))
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
187 return ComplexMatrix ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
188
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
189 ComplexMatrix atmp = a.hermitian ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
190 ComplexMatrix btmp = b.hermitian ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
191 MatrixType btyp = typ.transpose ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
192
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
193 octave_idx_type info;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
194 double rcond = 0.0;
3480
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
195
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
196 ComplexMatrix result
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
197 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
198
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
199 typ = btyp.transpose ();
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
200 return result.hermitian ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
201 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
202
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
203 // Funny element by element division operations.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
204 //
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
205 // op2 \ op1: s cs
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
206 // +-- +---+----+
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
207 // matrix | 1 | 3 |
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
208 // +---+----+
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
209 // complex_matrix | 2 | 4 |
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
210 // +---+----+
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
211
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
212 Matrix
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 1
diff changeset
213 x_el_div (double a, const Matrix& b)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
214 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
215 octave_idx_type nr = b.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
216 octave_idx_type nc = b.columns ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
217
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
218 Matrix result (nr, nc);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
219
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
220 for (octave_idx_type j = 0; j < nc; j++)
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
221 for (octave_idx_type i = 0; i < nr; i++)
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
222 {
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
223 OCTAVE_QUIT;
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
224 result (i, j) = a / b (i, j);
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
225 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
226
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
227 return result;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
228 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
229
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
230 ComplexMatrix
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 1
diff changeset
231 x_el_div (double a, const ComplexMatrix& b)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
232 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
233 octave_idx_type nr = b.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
234 octave_idx_type nc = b.columns ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
235
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
236 ComplexMatrix result (nr, nc);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
237
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
238 for (octave_idx_type j = 0; j < nc; j++)
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
239 for (octave_idx_type i = 0; i < nr; i++)
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
240 {
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
241 OCTAVE_QUIT;
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
242 result (i, j) = a / b (i, j);
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
243 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
244
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
245 return result;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
246 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
247
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
248 ComplexMatrix
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 1
diff changeset
249 x_el_div (const Complex a, const Matrix& b)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
250 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
251 octave_idx_type nr = b.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
252 octave_idx_type nc = b.columns ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
253
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
254 ComplexMatrix result (nr, nc);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
255
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
256 for (octave_idx_type j = 0; j < nc; j++)
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
257 for (octave_idx_type i = 0; i < nr; i++)
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
258 {
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
259 OCTAVE_QUIT;
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
260 result (i, j) = a / b (i, j);
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
261 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
262
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
263 return result;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
264 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
265
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
266 ComplexMatrix
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 1
diff changeset
267 x_el_div (const Complex a, const ComplexMatrix& b)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
268 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
269 octave_idx_type nr = b.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
270 octave_idx_type nc = b.columns ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
271
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
272 ComplexMatrix result (nr, nc);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
273
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
274 for (octave_idx_type j = 0; j < nc; j++)
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
275 for (octave_idx_type i = 0; i < nr; i++)
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
276 {
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
277 OCTAVE_QUIT;
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
278 result (i, j) = a / b (i, j);
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 3719
diff changeset
279 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
280
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
281 return result;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
282 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
283
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
284 // Funny element by element division operations.
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
285 //
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
286 // op2 \ op1: s cs
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
287 // +-- +---+----+
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
288 // N-d array | 1 | 3 |
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
289 // +---+----+
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
290 // complex N-d array | 2 | 4 |
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
291 // +---+----+
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
292
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
293 NDArray
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
294 x_el_div (double a, const NDArray& b)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
295 {
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
296 NDArray result (b.dims ());
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
297
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
298 for (octave_idx_type i = 0; i < b.length (); i++)
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
299 {
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
300 OCTAVE_QUIT;
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
301 result (i) = a / b (i);
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
302 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
303
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
304 return result;
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
305 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
306
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
307 ComplexNDArray
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
308 x_el_div (double a, const ComplexNDArray& b)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
309 {
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
310 ComplexNDArray result (b.dims ());
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
311
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
312 for (octave_idx_type i = 0; i < b.length (); i++)
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
313 {
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
314 OCTAVE_QUIT;
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
315 result (i) = a / b (i);
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
316 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
317
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
318 return result;
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
319 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
320
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
321 ComplexNDArray
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
322 x_el_div (const Complex a, const NDArray& b)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
323 {
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
324 ComplexNDArray result (b.dims ());
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
325
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
326 for (octave_idx_type i = 0; i < b.length (); i++)
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
327 {
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
328 OCTAVE_QUIT;
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
329 result (i) = a / b (i);
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
330 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
331
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
332 return result;
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
333 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
334
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
335 ComplexNDArray
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
336 x_el_div (const Complex a, const ComplexNDArray& b)
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
337 {
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
338 ComplexNDArray result (b.dims ());
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
339
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
340 for (octave_idx_type i = 0; i < b.length (); i++)
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
341 {
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
342 OCTAVE_QUIT;
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
343 result (i) = a / b (i);
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
344 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
345
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
346 return result;
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
347 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4153
diff changeset
348
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
349 // Left division functions.
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
350 //
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
351 // op2 \ op1: m cm
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
352 // +-- +---+----+
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
353 // matrix | 1 | 3 |
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
354 // +---+----+
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
355 // complex_matrix | 2 | 4 |
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
356 // +---+----+
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
357
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
358 // -*- 1 -*-
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
359 Matrix
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
360 xleftdiv (const Matrix& a, const Matrix& b, MatrixType &typ)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
361 {
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
362 if (! mx_leftdiv_conform (a, b))
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
363 return Matrix ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
364
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
365 octave_idx_type info;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
366 double rcond = 0.0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
367 return a.solve (typ, b, info, rcond, solve_singularity_warning);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
368 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
369
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
370 // -*- 2 -*-
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
371 ComplexMatrix
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
372 xleftdiv (const Matrix& a, const ComplexMatrix& b, MatrixType &typ)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
373 {
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
374 if (! mx_leftdiv_conform (a, b))
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
375 return ComplexMatrix ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
376
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
377 octave_idx_type info;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
378 double rcond = 0.0;
3480
45742a3b1f7c [project @ 2000-01-26 06:16:41 by jwe]
jwe
parents: 3195
diff changeset
379
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
380 return a.solve (typ, b, info, rcond, solve_singularity_warning);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
381 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
382
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
383 // -*- 3 -*-
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
384 ComplexMatrix
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
385 xleftdiv (const ComplexMatrix& a, const Matrix& b, MatrixType &typ)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
386 {
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
387 if (! mx_leftdiv_conform (a, b))
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
388 return ComplexMatrix ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
389
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
390 octave_idx_type info;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
391 double rcond = 0.0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
392 return a.solve (typ, b, info, rcond, solve_singularity_warning);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
393 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
394
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 453
diff changeset
395 // -*- 4 -*-
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
396 ComplexMatrix
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
397 xleftdiv (const ComplexMatrix& a, const ComplexMatrix& b, MatrixType &typ)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
398 {
2364
5eb0af0730d6 [project @ 1996-10-11 22:57:03 by jwe]
jwe
parents: 2305
diff changeset
399 if (! mx_leftdiv_conform (a, b))
1800
024c75af53f1 [project @ 1996-01-29 05:55:45 by jwe]
jwe
parents: 1742
diff changeset
400 return ComplexMatrix ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
401
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4669
diff changeset
402 octave_idx_type info;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
403 double rcond = 0.0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5307
diff changeset
404 return a.solve (typ, b, info, rcond, solve_singularity_warning);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
405 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
406
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
407 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
408 ;;; Local Variables: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
409 ;;; mode: C++ ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
410 ;;; End: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
411 */