annotate libinterp/corefcn/sparse-xdiv.cc @ 31605:e88a07dec498 stable

maint: Use macros to begin/end C++ namespaces. * oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE, OCTAVE_END_NAMESPACE) that can be used to start/end a namespace. * mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc, __dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc, auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc, display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc, help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h, mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc, pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, __delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc, audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh, mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 14:23:45 -0800
parents 796f54d4ddbf
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
3 // Copyright (C) 1998-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21723
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
28 #endif
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
29
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
30 #include <cassert>
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
31
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
32 #include "Array-util.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21024
diff changeset
33 #include "lo-array-errwarn.h"
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
34 #include "oct-cmplx.h"
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
35 #include "quit.h"
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
36 #include "error.h"
9003
0631d397fbe0 replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents: 8965
diff changeset
37 #include "lo-ieee.h"
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
38
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
39 #include "dSparse.h"
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
40 #include "dDiagMatrix.h"
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
41 #include "CSparse.h"
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
42 #include "CDiagMatrix.h"
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
43 #include "oct-spparms.h"
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
44 #include "sparse-xdiv.h"
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
45
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
46 OCTAVE_BEGIN_NAMESPACE(octave)
29990
b839c36fd106 move sparse xdiv and xpow operator functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
47
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
48 static void
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
49 solve_singularity_warning (double rcond)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
50 {
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
51 octave::warn_singular_matrix (rcond);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
52 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
53
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21112
diff changeset
54 template <typename T1, typename T2>
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
55 bool
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
56 mx_leftdiv_conform (const T1& a, const T2& b)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
57 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
58 octave_idx_type a_nr = a.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
59 octave_idx_type b_nr = b.rows ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
60
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
61 if (a_nr != b_nr)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
62 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
63 octave_idx_type a_nc = a.cols ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
64 octave_idx_type b_nc = b.cols ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
65
23804
8057d3f0673d Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents: 23433
diff changeset
66 octave::err_nonconformant (R"(operator \)", a_nr, a_nc, b_nr, b_nc);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
67 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
68
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
69 return true;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
70 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
71
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
72 #define INSTANTIATE_MX_LEFTDIV_CONFORM(T1, T2) \
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
73 template bool mx_leftdiv_conform (const T1&, const T2&)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
74
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
75 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, SparseMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
76 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, SparseComplexMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
77 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, SparseMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
78 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, SparseComplexMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
79 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, Matrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
80 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, ComplexMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
81 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, Matrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
82 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, ComplexMatrix);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
83 INSTANTIATE_MX_LEFTDIV_CONFORM (DiagMatrix, SparseMatrix);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
84 INSTANTIATE_MX_LEFTDIV_CONFORM (DiagMatrix, SparseComplexMatrix);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
85 INSTANTIATE_MX_LEFTDIV_CONFORM (ComplexDiagMatrix, SparseMatrix);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
86 INSTANTIATE_MX_LEFTDIV_CONFORM (ComplexDiagMatrix, SparseComplexMatrix);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
87
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21112
diff changeset
88 template <typename T1, typename T2>
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
89 bool
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
90 mx_div_conform (const T1& a, const T2& b)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
91 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
92 octave_idx_type a_nc = a.cols ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
93 octave_idx_type b_nc = b.cols ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
94
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
95 if (a_nc != b_nc)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
96 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
97 octave_idx_type a_nr = a.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
98 octave_idx_type b_nr = b.rows ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
99
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
100 octave::err_nonconformant ("operator /", a_nr, a_nc, b_nr, b_nc);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
101 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
102
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
103 return true;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
104 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
105
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
106 #define INSTANTIATE_MX_DIV_CONFORM(T1, T2) \
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
107 template bool mx_div_conform (const T1&, const T2&)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
108
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
109 INSTANTIATE_MX_DIV_CONFORM (SparseMatrix, SparseMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
110 INSTANTIATE_MX_DIV_CONFORM (SparseMatrix, SparseComplexMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
111 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, SparseMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
112 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, SparseComplexMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
113 INSTANTIATE_MX_DIV_CONFORM (Matrix, SparseMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
114 INSTANTIATE_MX_DIV_CONFORM (Matrix, SparseComplexMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
115 INSTANTIATE_MX_DIV_CONFORM (ComplexMatrix, SparseMatrix);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
116 INSTANTIATE_MX_DIV_CONFORM (ComplexMatrix, SparseComplexMatrix);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
117 INSTANTIATE_MX_DIV_CONFORM (SparseMatrix, DiagMatrix);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
118 INSTANTIATE_MX_DIV_CONFORM (SparseMatrix, ComplexDiagMatrix);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
119 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, DiagMatrix);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
120 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, ComplexDiagMatrix);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
121
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
122 // Right division functions. X / Y = X * inv (Y) = (inv (Y') * X')'
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
123 //
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
124 // Y / X: m cm sm scm
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
125 // +-- +---+----+----+----+
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
126 // sparse matrix | 1 | 3 | 5 | 7 |
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
127 // +---+----+----+----+
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
128 // sparse complex_matrix | 2 | 4 | 6 | 8 |
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
129 // +---+----+----+----+
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
130 // diagonal matrix | 9 | 11 |
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
131 // +----+----+
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
132 // complex diag. matrix | 10 | 12 |
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
133 // +----+----+
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
134
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
135 // -*- 1 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
136 Matrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
137 xdiv (const Matrix& a, const SparseMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
138 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
139 if (! mx_div_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
140 return Matrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
141
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
142 Matrix atmp = a.transpose ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
143 SparseMatrix btmp = b.transpose ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5681
diff changeset
144 MatrixType btyp = typ.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
145
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
146 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
147 double rcond = 0.0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
148 Matrix result = btmp.solve (btyp, atmp, info, rcond,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
149 solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
150
5322
22994a5730f9 [project @ 2005-04-29 13:04:24 by dbateman]
dbateman
parents: 5307
diff changeset
151 typ = btyp.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
152 return result.transpose ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
153 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
154
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
155 // -*- 2 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
156 ComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
157 xdiv (const Matrix& a, const SparseComplexMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
158 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
159 if (! mx_div_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
160 return ComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
161
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
162 Matrix atmp = a.transpose ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
163 SparseComplexMatrix btmp = b.hermitian ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5681
diff changeset
164 MatrixType btyp = typ.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
165
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
166 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
167 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
168 ComplexMatrix result
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
169 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
170
5322
22994a5730f9 [project @ 2005-04-29 13:04:24 by dbateman]
dbateman
parents: 5307
diff changeset
171 typ = btyp.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
172 return result.hermitian ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
173 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
174
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
175 // -*- 3 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
176 ComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
177 xdiv (const ComplexMatrix& a, const SparseMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
178 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
179 if (! mx_div_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
180 return ComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
181
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
182 ComplexMatrix atmp = a.hermitian ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
183 SparseMatrix btmp = b.transpose ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5681
diff changeset
184 MatrixType btyp = typ.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
185
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
186 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
187 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
188 ComplexMatrix result
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
189 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
190
5322
22994a5730f9 [project @ 2005-04-29 13:04:24 by dbateman]
dbateman
parents: 5307
diff changeset
191 typ = btyp.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
192 return result.hermitian ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
193 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
194
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
195 // -*- 4 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
196 ComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
197 xdiv (const ComplexMatrix& a, const SparseComplexMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
198 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
199 if (! mx_div_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
200 return ComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
201
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
202 ComplexMatrix atmp = a.hermitian ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
203 SparseComplexMatrix btmp = b.hermitian ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5681
diff changeset
204 MatrixType btyp = typ.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
205
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
206 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
207 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
208 ComplexMatrix result
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
209 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
210
5322
22994a5730f9 [project @ 2005-04-29 13:04:24 by dbateman]
dbateman
parents: 5307
diff changeset
211 typ = btyp.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
212 return result.hermitian ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
213 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
214
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
215 // -*- 5 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
216 SparseMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
217 xdiv (const SparseMatrix& a, const SparseMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
218 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
219 if (! mx_div_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
220 return SparseMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
221
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
222 SparseMatrix atmp = a.transpose ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
223 SparseMatrix btmp = b.transpose ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5681
diff changeset
224 MatrixType btyp = typ.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
225
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
226 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
227 double rcond = 0.0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
228 SparseMatrix result = btmp.solve (btyp, atmp, info, rcond,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
229 solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
230
5322
22994a5730f9 [project @ 2005-04-29 13:04:24 by dbateman]
dbateman
parents: 5307
diff changeset
231 typ = btyp.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
232 return result.transpose ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
233 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
234
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
235 // -*- 6 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
236 SparseComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
237 xdiv (const SparseMatrix& a, const SparseComplexMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
238 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
239 if (! mx_div_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
240 return SparseComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
241
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
242 SparseMatrix atmp = a.transpose ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
243 SparseComplexMatrix btmp = b.hermitian ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5681
diff changeset
244 MatrixType btyp = typ.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
245
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
246 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
247 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
248 SparseComplexMatrix result
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
249 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
250
5322
22994a5730f9 [project @ 2005-04-29 13:04:24 by dbateman]
dbateman
parents: 5307
diff changeset
251 typ = btyp.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
252 return result.hermitian ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
253 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
254
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
255 // -*- 7 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
256 SparseComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
257 xdiv (const SparseComplexMatrix& a, const SparseMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
258 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
259 if (! mx_div_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
260 return SparseComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
261
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
262 SparseComplexMatrix atmp = a.hermitian ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
263 SparseMatrix btmp = b.transpose ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5681
diff changeset
264 MatrixType btyp = typ.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
265
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
266 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
267 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
268 SparseComplexMatrix result
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
269 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
270
5322
22994a5730f9 [project @ 2005-04-29 13:04:24 by dbateman]
dbateman
parents: 5307
diff changeset
271 typ = btyp.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
272 return result.hermitian ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
273 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
274
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
275 // -*- 8 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
276 SparseComplexMatrix
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
277 xdiv (const SparseComplexMatrix& a, const SparseComplexMatrix& b,
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
278 MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
279 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
280 if (! mx_div_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
281 return SparseComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
282
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
283 SparseComplexMatrix atmp = a.hermitian ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
284 SparseComplexMatrix btmp = b.hermitian ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5681
diff changeset
285 MatrixType btyp = typ.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
286
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
287 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
288 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
289 SparseComplexMatrix result
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
290 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
291
5322
22994a5730f9 [project @ 2005-04-29 13:04:24 by dbateman]
dbateman
parents: 5307
diff changeset
292 typ = btyp.transpose ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
293 return result.hermitian ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
294 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
295
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
296 template <typename RT, typename SM, typename DM>
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
297 RT do_rightdiv_sm_dm (const SM& a, const DM& d)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
298 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
299 const octave_idx_type d_nr = d.rows ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
300
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
301 const octave_idx_type a_nr = a.rows ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
302 const octave_idx_type a_nc = a.cols ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
303
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
304 using std::min;
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
305 const octave_idx_type nc = min (d_nr, a_nc);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
306
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 17787
diff changeset
307 if (! mx_div_conform (a, d))
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
308 return RT ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
309
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
310 const octave_idx_type nz = a.nnz ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
311 RT r (a_nr, nc, nz);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
312
9196
c229bfb14d8d avoid apparent MSVC bug with typedef
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
313 typedef typename DM::element_type DM_elt_type;
c229bfb14d8d avoid apparent MSVC bug with typedef
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
314 const DM_elt_type zero = DM_elt_type ();
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
315
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
316 octave_idx_type k_result = 0;
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
317 for (octave_idx_type j = 0; j < nc; ++j)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
318 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 9245
diff changeset
319 octave_quit ();
9196
c229bfb14d8d avoid apparent MSVC bug with typedef
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
320 const DM_elt_type s = d.dgelem (j);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
321 const octave_idx_type colend = a.cidx (j+1);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
322 r.xcidx (j) = k_result;
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
323 if (s != zero)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
324 for (octave_idx_type k = a.cidx (j); k < colend; ++k)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
325 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
326 r.xdata (k_result) = a.data (k) / s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
327 r.xridx (k_result) = a.ridx (k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
328 ++k_result;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
329 }
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
330 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
331 r.xcidx (nc) = k_result;
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
332
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
333 r.maybe_compress (true);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
334 return r;
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
335 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
336
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
337 // -*- 9 -*-
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
338 SparseMatrix
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29990
diff changeset
339 xdiv (const SparseMatrix& a, const DiagMatrix& b, MatrixType&)
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
340 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
341 return do_rightdiv_sm_dm<SparseMatrix> (a, b);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
342 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
343
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
344 // -*- 10 -*-
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
345 SparseComplexMatrix
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29990
diff changeset
346 xdiv (const SparseMatrix& a, const ComplexDiagMatrix& b, MatrixType&)
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
347 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
348 return do_rightdiv_sm_dm<SparseComplexMatrix> (a, b);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
349 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
350
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
351 // -*- 11 -*-
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
352 SparseComplexMatrix
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29990
diff changeset
353 xdiv (const SparseComplexMatrix& a, const DiagMatrix& b, MatrixType&)
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
354 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
355 return do_rightdiv_sm_dm<SparseComplexMatrix> (a, b);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
356 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
357
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
358 // -*- 12 -*-
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
359 SparseComplexMatrix
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29990
diff changeset
360 xdiv (const SparseComplexMatrix& a, const ComplexDiagMatrix& b, MatrixType&)
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
361 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
362 return do_rightdiv_sm_dm<SparseComplexMatrix> (a, b);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
363 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
364
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
365 // Funny element by element division operations.
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
366 //
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
367 // op2 \ op1: s cs
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
368 // +-- +---+----+
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
369 // matrix | 1 | 3 |
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
370 // +---+----+
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
371 // complex_matrix | 2 | 4 |
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
372 // +---+----+
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
373
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
374 Matrix
29990
b839c36fd106 move sparse xdiv and xpow operator functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
375 elem_xdiv (double a, const SparseMatrix& b)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
376 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
377 octave_idx_type nr = b.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
378 octave_idx_type nc = b.cols ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
379
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
380 Matrix result;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
381 if (a == 0.)
21723
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
382 result = Matrix (nr, nc, octave::numeric_limits<double>::NaN ());
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
383 else if (a > 0.)
21723
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
384 result = Matrix (nr, nc, octave::numeric_limits<double>::Inf ());
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
385 else
21723
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
386 result = Matrix (nr, nc, -octave::numeric_limits<double>::Inf ());
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
387
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
388 for (octave_idx_type j = 0; j < nc; j++)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
389 for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
390 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
391 octave_quit ();
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
392 result.elem (b.ridx (i), j) = a / b.data (i);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
393 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
394
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
395 return result;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
396 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
397
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
398 ComplexMatrix
29990
b839c36fd106 move sparse xdiv and xpow operator functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
399 elem_xdiv (double a, const SparseComplexMatrix& b)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
400 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
401 octave_idx_type nr = b.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
402 octave_idx_type nc = b.cols ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
403
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
404 ComplexMatrix result (nr, nc, Complex (octave::numeric_limits<double>::NaN (),
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22327
diff changeset
405 octave::numeric_limits<double>::NaN ()));
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
406
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
407 for (octave_idx_type j = 0; j < nc; j++)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
408 for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
409 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
410 octave_quit ();
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
411 result.elem (b.ridx (i), j) = a / b.data (i);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
412 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
413
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
414 return result;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
415 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
416
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
417 ComplexMatrix
29990
b839c36fd106 move sparse xdiv and xpow operator functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
418 elem_xdiv (const Complex& a, const SparseMatrix& b)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
419 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
420 octave_idx_type nr = b.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
421 octave_idx_type nc = b.cols ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
422
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
423 ComplexMatrix result (nr, nc, (a / 0.0));
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
424
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
425 for (octave_idx_type j = 0; j < nc; j++)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
426 for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
427 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
428 octave_quit ();
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
429 result.elem (b.ridx (i), j) = a / b.data (i);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
430 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
431
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
432 return result;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
433 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
434
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
435 ComplexMatrix
29990
b839c36fd106 move sparse xdiv and xpow operator functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
436 elem_xdiv (const Complex& a, const SparseComplexMatrix& b)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
437 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
438 octave_idx_type nr = b.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
439 octave_idx_type nc = b.cols ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
440
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
441 ComplexMatrix result (nr, nc, (a / 0.0));
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
442
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
443 for (octave_idx_type j = 0; j < nc; j++)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
444 for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
445 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
446 octave_quit ();
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
447 result.elem (b.ridx (i), j) = a / b.data (i);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
448 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
449
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
450 return result;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
451 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
452
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
453 // Left division functions. X \ Y = inv (X) * Y
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
454 //
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
455 // Y \ X : sm scm dm dcm
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
456 // +-- +---+----+
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
457 // matrix | 1 | 5 |
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
458 // +---+----+
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
459 // complex_matrix | 2 | 6 |
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
460 // +---+----+----+----+
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
461 // sparse matrix | 3 | 7 | 9 | 11 |
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
462 // +---+----+----+----+
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
463 // sparse complex_matrix | 4 | 8 | 10 | 12 |
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
464 // +---+----+----+----+
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
465
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
466 // -*- 1 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
467 Matrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
468 xleftdiv (const SparseMatrix& a, const Matrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
469 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
470 if (! mx_leftdiv_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
471 return Matrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
472
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
473 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
474 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
475 return a.solve (typ, b, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
476 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
477
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
478 // -*- 2 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
479 ComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
480 xleftdiv (const SparseMatrix& a, const ComplexMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
481 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
482 if (! mx_leftdiv_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
483 return ComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
484
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
485 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
486 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
487 return a.solve (typ, b, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
488 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
489
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
490 // -*- 3 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
491 SparseMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
492 xleftdiv (const SparseMatrix& a, const SparseMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
493 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
494 if (! mx_leftdiv_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
495 return SparseMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
496
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
497 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
498 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
499 return a.solve (typ, b, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
500 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
501
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
502 // -*- 4 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
503 SparseComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
504 xleftdiv (const SparseMatrix& a, const SparseComplexMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
505 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
506 if (! mx_leftdiv_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
507 return SparseComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
508
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
509 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
510 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
511 return a.solve (typ, b, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
512 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
513
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
514 // -*- 5 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
515 ComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
516 xleftdiv (const SparseComplexMatrix& a, const Matrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
517 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
518 if (! mx_leftdiv_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
519 return ComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
520
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
521 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
522 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
523 return a.solve (typ, b, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
524 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
525
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
526 // -*- 6 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
527 ComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
528 xleftdiv (const SparseComplexMatrix& a, const ComplexMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
529 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
530 if (! mx_leftdiv_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
531 return ComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
532
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
533 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
534 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
535 return a.solve (typ, b, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
536 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
537
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
538 // -*- 7 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
539 SparseComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
540 xleftdiv (const SparseComplexMatrix& a, const SparseMatrix& b, MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
541 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
542 if (! mx_leftdiv_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
543 return SparseComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
544
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
545 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
546 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
547 return a.solve (typ, b, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
548 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
549
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
550 // -*- 8 -*-
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
551 SparseComplexMatrix
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
552 xleftdiv (const SparseComplexMatrix& a, const SparseComplexMatrix& b,
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
553 MatrixType& typ)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
554 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
555 if (! mx_leftdiv_conform (a, b))
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
556 return SparseComplexMatrix ();
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
557
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
558 octave_idx_type info;
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
559 double rcond = 0.0;
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5610
diff changeset
560 return a.solve (typ, b, info, rcond, solve_singularity_warning);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
561 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
562
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
563 template <typename RT, typename DM, typename SM>
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
564 RT do_leftdiv_dm_sm (const DM& d, const SM& a)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
565 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
566 const octave_idx_type a_nr = a.rows ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
567 const octave_idx_type a_nc = a.cols ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
568
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
569 const octave_idx_type d_nc = d.cols ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
570
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
571 using std::min;
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
572 const octave_idx_type nr = min (d_nc, a_nr);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
573
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 17787
diff changeset
574 if (! mx_leftdiv_conform (d, a))
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
575 return RT ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
576
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
577 const octave_idx_type nz = a.nnz ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
578 RT r (nr, a_nc, nz);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
579
9196
c229bfb14d8d avoid apparent MSVC bug with typedef
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
580 typedef typename DM::element_type DM_elt_type;
c229bfb14d8d avoid apparent MSVC bug with typedef
John W. Eaton <jwe@octave.org>
parents: 9003
diff changeset
581 const DM_elt_type zero = DM_elt_type ();
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
582
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
583 octave_idx_type k_result = 0;
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
584 for (octave_idx_type j = 0; j < a_nc; ++j)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
585 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 9245
diff changeset
586 octave_quit ();
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
587 const octave_idx_type colend = a.cidx (j+1);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
588 r.xcidx (j) = k_result;
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
589 for (octave_idx_type k = a.cidx (j); k < colend; ++k)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
590 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
591 const octave_idx_type i = a.ridx (k);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
592 if (i < nr)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
593 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
594 const DM_elt_type s = d.dgelem (i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
595 if (s != zero)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
596 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
597 r.xdata (k_result) = a.data (k) / s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
598 r.xridx (k_result) = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
599 ++k_result;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
600 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
601 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
602 }
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
603 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
604 r.xcidx (a_nc) = k_result;
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
605
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
606 r.maybe_compress (true);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
607 return r;
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
608 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
609
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
610 // -*- 9 -*-
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
611 SparseMatrix
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
612 xleftdiv (const DiagMatrix& d, const SparseMatrix& a, MatrixType&)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
613 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
614 return do_leftdiv_dm_sm<SparseMatrix> (d, a);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
615 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
616
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
617 // -*- 10 -*-
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
618 SparseComplexMatrix
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
619 xleftdiv (const DiagMatrix& d, const SparseComplexMatrix& a, MatrixType&)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
620 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
621 return do_leftdiv_dm_sm<SparseComplexMatrix> (d, a);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
622 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
623
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
624 // -*- 11 -*-
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
625 SparseComplexMatrix
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
626 xleftdiv (const ComplexDiagMatrix& d, const SparseMatrix& a, MatrixType&)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
627 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
628 return do_leftdiv_dm_sm<SparseComplexMatrix> (d, a);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
629 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
630
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
631 // -*- 12 -*-
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
632 SparseComplexMatrix
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
633 xleftdiv (const ComplexDiagMatrix& d, const SparseComplexMatrix& a,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
634 MatrixType&)
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
635 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
636 return do_leftdiv_dm_sm<SparseComplexMatrix> (d, a);
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 7017
diff changeset
637 }
29990
b839c36fd106 move sparse xdiv and xpow operator functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
638
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
639 OCTAVE_END_NAMESPACE(octave)