comparison libinterp/corefcn/kron.cc @ 30723:08b08b7f05b2

Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753) Define 4 new inline functions in error.h (panic_if, panic_unless, error_if, error_unless) that call either assert() or Octave's own error() function. Replace calls to assert() in code that maintains state and for which no recovery on detection of a problem is possible with calls to panic_XXX. Replace calls to assert() in interpreter code which could simply return to the Octave prompt when a problem is detected with calls to error_XXX. * error.h (panic_if, panic_unless): New functions which eventually call can call assert(). panic_if (COND) calls assert if COND is true. panic_unless (COND) calls assert if COND is false. * error.h (error_if, error_unless): New functions which eventually call can call Octave's error() function. error_if (COND) calls assert if COND is true. error_unless (COND) calls assert if COND is false. * cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, dot.cc, error.cc, graphics.cc, kron.cc, mex.cc, oct-map.cc, oct-stream.cc, pr-output.cc, schur.cc, stack-frame.cc, typecast.cc, variables.cc, ov-base.cc, ov-class.cc, ov-fcn-handle.cc, ov-struct.cc, ov-usr-fcn.cc, ov.h, ovl.cc, ops.h, profiler.cc, pt-classdef.cc, pt-eval.cc, pt-idx.cc, pt-pr-code.cc, pt-tm-const.cc, token.cc: Replace direct calls to C library assert() with Octave specialty functions.
author Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
date Mon, 07 Feb 2022 21:47:53 -0800
parents 796f54d4ddbf
children 32d2b6604a9f
comparison
equal deleted inserted replaced
30720:25de51cb4123 30723:08b08b7f05b2
53 53
54 template <typename R, typename T> 54 template <typename R, typename T>
55 static MArray<T> 55 static MArray<T>
56 kron (const MArray<R>& a, const MArray<T>& b) 56 kron (const MArray<R>& a, const MArray<T>& b)
57 { 57 {
58 assert (a.ndims () == 2); 58 error_unless (a.ndims () == 2);
59 assert (b.ndims () == 2); 59 error_unless (b.ndims () == 2);
60 60
61 octave_idx_type nra = a.rows (); 61 octave_idx_type nra = a.rows ();
62 octave_idx_type nrb = b.rows (); 62 octave_idx_type nrb = b.rows ();
63 octave_idx_type nca = a.cols (); 63 octave_idx_type nca = a.cols ();
64 octave_idx_type ncb = b.cols (); 64 octave_idx_type ncb = b.cols ();
84 84
85 template <typename R, typename T> 85 template <typename R, typename T>
86 static MArray<T> 86 static MArray<T>
87 kron (const MDiagArray2<R>& a, const MArray<T>& b) 87 kron (const MDiagArray2<R>& a, const MArray<T>& b)
88 { 88 {
89 assert (b.ndims () == 2); 89 error_unless (b.ndims () == 2);
90 90
91 octave_idx_type nra = a.rows (); 91 octave_idx_type nra = a.rows ();
92 octave_idx_type nrb = b.rows (); 92 octave_idx_type nrb = b.rows ();
93 octave_idx_type dla = a.diag_length (); 93 octave_idx_type dla = a.diag_length ();
94 octave_idx_type nca = a.cols (); 94 octave_idx_type nca = a.cols ();