Mercurial > octave
annotate libinterp/corefcn/betainc.cc @ 21200:fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
* builtins.h, Cell.cc, __contourc__.cc, __dispatch__.cc, __dsearchn__.cc,
__ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __pchip_deriv__.cc, __qp__.cc,
balance.cc, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc,
c-file-ptr-stream.cc, c-file-ptr-stream.h, cellfun.cc, colloc.cc,
comment-list.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc,
defaults.cc, defaults.in.h, defun-dld.h, defun.cc, defun.h, det.cc, dirfns.cc,
display.cc, dlmread.cc, dot.cc, dynamic-ld.cc, eig.cc, ellipj.cc, error.cc,
errwarn.cc, event-queue.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc,
find.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc,
givens.cc, gl-render.cc, gl2ps-print.cc, graphics.cc, graphics.in.h, gripes.cc,
hash.cc, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, jit-ir.cc,
jit-typeinfo.cc, jit-util.cc, jit-util.h, kron.cc, load-path.cc, load-save.cc,
lookup.cc, ls-ascii-helper.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc,
ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, ls-oct-text.h, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, luinc.cc, mappers.cc, matrix_type.cc, max.cc,
mex.h, mexproto.h, mgorth.cc, nproc.cc, oct-errno.in.cc, oct-fstrm.cc,
oct-hdf5-types.cc, oct-hdf5.h, oct-hist.cc, oct-iostrm.cc, oct-lvalue.cc,
oct-map.cc, oct-prcstrm.cc, oct-procbuf.cc, oct-stream.cc, oct-strstrm.cc,
octave-link.cc, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, procstream.cc,
profiler.cc, psi.cc, pt-jit.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc,
regexp.cc, schur.cc, sighandlers.cc, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc,
spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc,
sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, sysdep.h, time.cc, toplev.cc,
tril.cc, tsearch.cc, txt-eng-ft.cc, txt-eng.cc, typecast.cc, urlwrite.cc,
utils.cc, variables.cc, xdiv.cc, xnorm.cc, xpow.cc, zfstream.cc,
__delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc,
__init_fltk__.cc, __init_gnuplot__.cc, __magick_read__.cc, __osmesa_print__.cc,
__voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc,
colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, oct-qhull.h, qr.cc, symbfact.cc,
symrcm.cc, oct-conf.in.cc, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc,
ov-base-scalar.cc, ov-base-sparse.cc, ov-base.cc, ov-bool-mat.cc,
ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-ch-mat.cc,
ov-class.cc, ov-classdef.cc, ov-colon.cc, ov-complex.cc, ov-cs-list.cc,
ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-fcn-handle.cc,
ov-fcn-inline.cc, ov-fcn.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc,
ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-lazy-idx.cc,
ov-mex-fcn.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-perm.cc, ov-range.cc,
ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc,
ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc,
ov-uint8.cc, ov-usr-fcn.cc, ov.cc, ovl.cc, octave.cc, 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-double-conv.cc, op-fcdm-fcdm.cc,
op-fcdm-fdm.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-float-conv.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-int-conv.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-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, pt-arg-list.cc,
pt-array-list.cc, pt-assign.cc, pt-binop.cc, pt-bp.cc, pt-cbinop.cc,
pt-cell.cc, pt-check.cc, pt-classdef.cc, pt-cmd.cc, pt-colon.cc, pt-colon.h,
pt-const.cc, pt-decl.cc, pt-eval.cc, pt-except.cc, pt-exp.cc, pt-fcn-handle.cc,
pt-funcall.cc, pt-id.cc, pt-idx.cc, pt-jump.cc, pt-loop.cc, pt-mat.cc,
pt-misc.cc, pt-pr-code.cc, pt-select.cc, pt-stmt.cc, pt-unop.cc, pt.cc,
token.cc, Array-jit.cc, Array-os.cc, Array-sym.cc, Array-tc.cc, version.cc:
Indent #ifdef blocks in libinterp.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 05 Feb 2016 16:29:08 -0800 |
parents | e39e05d90788 |
children | 40de9f8f23a6 |
rev | line source |
---|---|
3254 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18517
diff
changeset
|
3 Copyright (C) 1997-2015 John W. Eaton |
3254 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
3254 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
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/>. | |
3254 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
24 # include <config.h> |
3254 | 25 #endif |
26 | |
27 #include "lo-specfun.h" | |
28 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14850
diff
changeset
|
29 #include "defun.h" |
3254 | 30 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
31 #include "errwarn.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20918
diff
changeset
|
32 #include "ovl.h" |
3254 | 33 #include "utils.h" |
34 | |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
35 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14850
diff
changeset
|
36 DEFUN (betainc, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
37 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20819
diff
changeset
|
38 @deftypefn {} {} betainc (@var{x}, @var{a}, @var{b})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
39 Compute the regularized incomplete Beta function.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
40 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
41 The regularized incomplete Beta function is defined by\n\ |
3444 | 42 @tex\n\ |
43 $$\n\ | |
12658
08f8fc1e9872
betainc.cc: Correctly refer to function as regularized incomplete Beta function.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
44 I (x, a, b) = {1 \\over {B (a, b)}} \\int_0^x t^{(a-z)} (1-t)^{(b-1)} dt.\n\ |
3444 | 45 $$\n\ |
46 @end tex\n\ | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7815
diff
changeset
|
47 @ifnottex\n\ |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
48 @c Set example in small font to prevent overfull line\n\ |
3254 | 49 \n\ |
3444 | 50 @smallexample\n\ |
10840 | 51 @group\n\ |
14437
62a2ef6c09a4
doc: Correct spacing of integrals in Info version of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
52 x\n\ |
62a2ef6c09a4
doc: Correct spacing of integrals in Info version of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
53 1 /\n\ |
62a2ef6c09a4
doc: Correct spacing of integrals in Info version of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
54 betainc (x, a, b) = ----------- | t^(a-1) (1-t)^(b-1) dt.\n\ |
62a2ef6c09a4
doc: Correct spacing of integrals in Info version of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
55 beta (a, b) /\n\ |
62a2ef6c09a4
doc: Correct spacing of integrals in Info version of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
56 t=0\n\ |
10840 | 57 @end group\n\ |
3444 | 58 @end smallexample\n\ |
10840 | 59 \n\ |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7815
diff
changeset
|
60 @end ifnottex\n\ |
3254 | 61 \n\ |
12776
944cf42c699e
doc: small documentation fixes for strftime, betainc
Rik <octave@nomad.inbox5.com>
parents:
12658
diff
changeset
|
62 If @var{x} has more than one component, both @var{a} and @var{b} must be\n\ |
3444 | 63 scalars. If @var{x} is a scalar, @var{a} and @var{b} must be of\n\ |
64 compatible dimensions.\n\ | |
14850
cfb64ea5c6a3
doc: Add Seealso links to betainc() docstring
Rik <octave@nomad.inbox5.com>
parents:
14817
diff
changeset
|
65 @seealso{betaincinv, beta, betaln}\n\ |
3444 | 66 @end deftypefn") |
3254 | 67 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
68 if (args.length () != 3) |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
69 print_usage (); |
3254 | 70 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
71 octave_value retval; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
72 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
73 octave_value x_arg = args(0); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
74 octave_value a_arg = args(1); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
75 octave_value b_arg = args(2); |
3254 | 76 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
77 // FIXME: Can we make a template version of the duplicated code below |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
78 if (x_arg.is_single_type () || a_arg.is_single_type () |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
79 || b_arg.is_single_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
80 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
81 if (x_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
82 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
83 float x = x_arg.float_value (); |
3254 | 84 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
85 if (a_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
86 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
87 float a = a_arg.float_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
88 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
89 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
90 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
91 float b = b_arg.float_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
92 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
93 retval = betainc (x, a, b); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
94 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
95 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
96 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
97 Array<float> b = b_arg.float_array_value (); |
3254 | 98 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
99 retval = betainc (x, a, b); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
100 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
101 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
102 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
103 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
104 Array<float> a = a_arg.float_array_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
105 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
106 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
107 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
108 float b = b_arg.float_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
109 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
110 retval = betainc (x, a, b); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
111 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
112 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
113 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
114 Array<float> b = b_arg.float_array_value (); |
3254 | 115 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
116 retval = betainc (x, a, b); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
117 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
118 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
119 } |
3254 | 120 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
121 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
122 Array<float> x = x_arg.float_array_value (); |
3254 | 123 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
124 if (a_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
125 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
126 float a = a_arg.float_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
127 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
128 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
129 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
130 float b = b_arg.float_value (); |
3254 | 131 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
132 retval = betainc (x, a, b); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
133 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
134 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
135 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
136 Array<float> b = b_arg.float_array_value (); |
3254 | 137 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
138 retval = betainc (x, a, b); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
139 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
140 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
141 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
142 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
143 Array<float> a = a_arg.float_array_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
144 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
145 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
146 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
147 float b = b_arg.float_value (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
148 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
149 retval = betainc (x, a, b); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
150 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
151 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
152 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
153 Array<float> b = b_arg.float_array_value (); |
3254 | 154 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
155 retval = betainc (x, a, b); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
156 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
157 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9758
diff
changeset
|
158 } |
3254 | 159 } |
160 else | |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
161 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
162 if (x_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
163 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
164 double x = x_arg.double_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
165 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
166 if (a_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
167 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
168 double a = a_arg.double_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
169 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
170 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
171 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
172 double b = b_arg.double_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
173 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
174 retval = betainc (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
175 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
176 else |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
177 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
178 Array<double> b = b_arg.array_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
179 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
180 retval = betainc (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
181 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
182 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
183 else |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
184 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
185 Array<double> a = a_arg.array_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
186 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
187 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
188 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
189 double b = b_arg.double_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
190 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
191 retval = betainc (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
192 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
193 else |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
194 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
195 Array<double> b = b_arg.array_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
196 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
197 retval = betainc (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
198 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
199 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
200 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
201 else |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
202 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
203 Array<double> x = x_arg.array_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
204 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
205 if (a_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
206 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
207 double a = a_arg.double_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
208 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
209 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
210 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
211 double b = b_arg.double_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
212 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
213 retval = betainc (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
214 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
215 else |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
216 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
217 Array<double> b = b_arg.array_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
218 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
219 retval = betainc (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
220 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
221 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
222 else |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
223 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
224 Array<double> a = a_arg.array_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
225 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
226 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
227 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
228 double b = b_arg.double_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
229 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
230 retval = betainc (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
231 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
232 else |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
233 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
234 Array<double> b = b_arg.array_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
235 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
236 retval = betainc (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
237 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
238 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
239 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
240 } |
3254 | 241 |
242 return retval; | |
243 } | |
244 | |
245 /* | |
14815
95b93a728603
Use Array superclass, rather than Matrix or NDArray, for betainc function.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
246 ## Double precision |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
247 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
248 %! a = [1, 1.5, 2, 3]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
249 %! b = [4, 3, 2, 1]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
250 %! v1 = betainc (1,a,b); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
251 %! v2 = [1,1,1,1]; |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
252 %! x = [.2, .4, .6, .8]; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
253 %! v3 = betainc (x, a, b); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
254 %! v4 = 1 - betainc (1.-x, b, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
255 %! assert (v1, v2, sqrt (eps)); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
256 %! assert (v3, v4, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
257 |
14815
95b93a728603
Use Array superclass, rather than Matrix or NDArray, for betainc function.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
258 ## Single precision |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
259 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
260 %! a = single ([1, 1.5, 2, 3]); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
261 %! b = single ([4, 3, 2, 1]); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
262 %! v1 = betainc (1,a,b); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
263 %! v2 = single ([1,1,1,1]); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
264 %! x = single ([.2, .4, .6, .8]); |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
265 %! v3 = betainc (x, a, b); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
266 %! v4 = 1 - betainc (1.-x, b, a); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
267 %! assert (v1, v2, sqrt (eps ("single"))); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
268 %! assert (v3, v4, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
269 |
14815
95b93a728603
Use Array superclass, rather than Matrix or NDArray, for betainc function.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
270 ## Mixed double/single precision |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
271 %!test |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
272 %! a = single ([1, 1.5, 2, 3]); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
273 %! b = [4, 3, 2, 1]; |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
274 %! v1 = betainc (1,a,b); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
275 %! v2 = single ([1,1,1,1]); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
276 %! x = [.2, .4, .6, .8]; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
277 %! v3 = betainc (x, a, b); |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14437
diff
changeset
|
278 %! v4 = 1-betainc (1.-x, b, a); |
14815
95b93a728603
Use Array superclass, rather than Matrix or NDArray, for betainc function.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
279 %! assert (v1, v2, sqrt (eps ("single"))); |
95b93a728603
Use Array superclass, rather than Matrix or NDArray, for betainc function.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
280 %! assert (v3, v4, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
281 |
14815
95b93a728603
Use Array superclass, rather than Matrix or NDArray, for betainc function.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
282 %!error betainc () |
95b93a728603
Use Array superclass, rather than Matrix or NDArray, for betainc function.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
283 %!error betainc (1) |
95b93a728603
Use Array superclass, rather than Matrix or NDArray, for betainc function.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
284 %!error betainc (1,2) |
95b93a728603
Use Array superclass, rather than Matrix or NDArray, for betainc function.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
285 %!error betainc (1,2,3,4) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
286 */ |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
287 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14850
diff
changeset
|
288 DEFUN (betaincinv, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
289 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20819
diff
changeset
|
290 @deftypefn {} {} betaincinv (@var{y}, @var{a}, @var{b})\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
291 Compute the inverse of the incomplete Beta function.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
292 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
293 The inverse is the value @var{x} such that\n\ |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
294 \n\ |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
295 @example\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
296 @var{y} == betainc (@var{x}, @var{a}, @var{b})\n\ |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
297 @end example\n\ |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
298 @seealso{betainc, beta, betaln}\n\ |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
299 @end deftypefn") |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
300 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
301 if (args.length () != 3) |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
302 print_usage (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
303 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
304 octave_value retval; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
305 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
306 octave_value x_arg = args(0); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
307 octave_value a_arg = args(1); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
308 octave_value b_arg = args(2); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
309 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
310 if (x_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
311 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
312 double x = x_arg.double_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
313 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
314 if (a_arg.is_scalar_type ()) |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
315 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
316 double a = a_arg.double_value (); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
317 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
318 if (b_arg.is_scalar_type ()) |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
319 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
320 double b = b_arg.double_value (); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
321 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
322 retval = betaincinv (x, a, b); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
323 } |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
324 else |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
325 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
326 Array<double> b = b_arg.array_value (); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
327 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
328 retval = betaincinv (x, a, b); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
329 } |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
330 } |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
331 else |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
332 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
333 Array<double> a = a_arg.array_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
334 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
335 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
336 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
337 double b = b_arg.double_value (); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
338 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
339 retval = betaincinv (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
340 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
341 else |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
342 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
343 Array<double> b = b_arg.array_value (); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
344 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
345 retval = betaincinv (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
346 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
347 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
348 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
349 else |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
350 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
351 Array<double> x = x_arg.array_value (); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
352 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
353 if (a_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
354 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
355 double a = a_arg.double_value (); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
356 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
357 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
358 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
359 double b = b_arg.double_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
360 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
361 retval = betaincinv (x, a, b); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
362 } |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
363 else |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
364 { |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
365 Array<double> b = b_arg.array_value (); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
366 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
367 retval = betaincinv (x, a, b); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
368 } |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
369 } |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
370 else |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
371 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
372 Array<double> a = a_arg.array_value (); |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
373 |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
374 if (b_arg.is_scalar_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
375 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
376 double b = b_arg.double_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
377 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
378 retval = betaincinv (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
379 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
380 else |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
381 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
382 Array<double> b = b_arg.array_value (); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
383 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
384 retval = betaincinv (x, a, b); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
385 } |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
386 } |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
387 } |
20802
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
388 |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
389 // FIXME: It would be better to have an algorithm for betaincinv which |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
390 // accepted float inputs and returned float outputs. As it is, we do |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
391 // extra work to calculate betaincinv to double precision and then throw |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
392 // that precision away. |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
393 if (x_arg.is_single_type () || a_arg.is_single_type () |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
394 || b_arg.is_single_type ()) |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
395 { |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
396 retval = Array<float> (retval.array_value ()); |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
397 } |
8bb38ba1bad6
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20561
diff
changeset
|
398 |
14817
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
399 return retval; |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
400 } |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
401 |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
402 /* |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
403 %!assert (betaincinv ([0.875 0.6875], [1 2], 3), [0.5 0.5], sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
404 %!assert (betaincinv (0.5, 3, 3), 0.5, sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
405 %!assert (betaincinv (0.34375, 4, 3), 0.5, sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
406 %!assert (betaincinv (0.2265625, 5, 3), 0.5, sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
407 %!assert (betaincinv (0.14453125, 6, 3), 0.5, sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
408 %!assert (betaincinv (0.08984375, 7, 3), 0.5, sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
409 %!assert (betaincinv (0.0546875, 8, 3), 0.5, sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
410 %!assert (betaincinv (0.03271484375, 9, 3), 0.5, sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
411 %!assert (betaincinv (0.019287109375, 10, 3), 0.5, sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
412 |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
413 ## Test class single as well |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
414 %!assert (betaincinv ([0.875 0.6875], [1 2], single (3)), [0.5 0.5], sqrt (eps ("single"))) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
415 %!assert (betaincinv (0.5, 3, single (3)), 0.5, sqrt (eps ("single"))) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
416 %!assert (betaincinv (0.34375, 4, single (3)), 0.5, sqrt (eps ("single"))) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
417 |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
418 ## Extreme values |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
419 %!assert (betaincinv (0, 42, 42), 0, sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
420 %!assert (betaincinv (1, 42, 42), 1, sqrt (eps)) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
421 |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
422 %!error betaincinv () |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
423 %!error betaincinv (1, 2) |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
424 */ |
67897baaa05f
Adapt implementation of betaincinv to Octave.
Rik <octave@nomad.inbox5.com>
parents:
14815
diff
changeset
|
425 |