Mercurial > octave
annotate libinterp/corefcn/colloc.cc @ 23803:90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
* parser.cc, workspace-view.cc, __lin_interpn__.cc, cellfun.cc, colloc.cc,
data.cc, dirfns.cc, eig.cc, file-io.cc, find.cc, gammainc.cc, gl2ps-print.cc,
graphics.cc, graphics.in.h, help.cc, input.cc, load-path.cc, load-save.cc,
oct-hist.cc, oct-stream.cc, pager.cc, pr-output.cc, spparms.cc, symtab.cc,
toplev.cc, tril.cc, urlwrite.cc, utils.cc, variables.cc, chol.cc, qr.cc,
symbfact.cc, ov-struct.cc, octave.cc, pt-id.h, version.cc, mkoctfile.in.cc:
Replace regular strings containing "\"" patterns with R"(..."...)".
author | Rik <rik@octave.org> |
---|---|
date | Fri, 28 Jul 2017 10:34:33 -0700 |
parents | 092078913d54 |
children | 194eb4bd202b |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1996-2017 John W. Eaton |
2928 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
10 (at your option) any later version. |
2928 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
15 GNU General Public License for more details. |
2928 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2928 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
24 # include "config.h" |
2928 | 25 #endif |
26 | |
27 #include <string> | |
28 | |
29 #include "CollocWt.h" | |
30 #include "lo-mappers.h" | |
31 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
32 #include "defun.h" |
2928 | 33 #include "error.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20918
diff
changeset
|
34 #include "ovl.h" |
2928 | 35 #include "utils.h" |
36 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
37 DEFUN (colloc, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
38 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
39 @deftypefn {} {[@var{r}, @var{amat}, @var{bmat}, @var{q}] =} colloc (@var{n}, "left", "right") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
40 Compute derivative and integral weight matrices for orthogonal collocation. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
41 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
42 Reference: @nospell{J. Villadsen}, @nospell{M. L. Michelsen}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
43 @cite{Solution of Differential Equation Models by Polynomial Approximation}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
44 @end deftypefn */) |
2928 | 45 { |
46 int nargin = args.length (); | |
47 | |
48 if (nargin < 1 || nargin > 3) | |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
49 print_usage (); |
2928 | 50 |
51 if (! args(0).is_scalar_type ()) | |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
52 error ("colloc: N must be a scalar"); |
2928 | 53 |
54 double tmp = args(0).double_value (); | |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
55 if (octave::math::isnan (tmp)) |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
56 error ("colloc: N cannot be NaN"); |
2928 | 57 |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
58 octave_idx_type ncol = octave::math::nint_big (tmp); |
2928 | 59 if (ncol < 0) |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
60 error ("colloc: N must be positive"); |
2928 | 61 |
5275 | 62 octave_idx_type ntot = ncol; |
63 octave_idx_type left = 0; | |
64 octave_idx_type right = 0; | |
2928 | 65 |
66 for (int i = 1; i < nargin; i++) | |
67 { | |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20700
diff
changeset
|
68 std::string s = args(i).xstring_value ("colloc: optional arguments must be strings"); |
2928 | 69 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
70 if ((s.length () == 1 && (s[0] == 'R' || s[0] == 'r')) || s == "right") |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
71 right = 1; |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
72 else if ((s.length () == 1 && (s[0] == 'L' || s[0] == 'l')) |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
73 || s == "left") |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
74 left = 1; |
2928 | 75 else |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
76 error (R"(colloc: string argument must be "left" or "right")"); |
2928 | 77 } |
78 | |
79 ntot += left + right; | |
80 if (ntot < 1) | |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
81 error ("colloc: the total number of roots must be positive"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
82 |
2928 | 83 CollocWt wts (ncol, left, right); |
84 | |
85 ColumnVector r = wts.roots (); | |
86 Matrix A = wts.first (); | |
87 Matrix B = wts.second (); | |
88 ColumnVector q = wts.quad_weights (); | |
89 | |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
90 return ovl (r, A, B, q); |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20884
diff
changeset
|
91 } |