changeset 33395:a258493e726a

Backed out changeset c714266d9f0d
author Arun Giridhar <arungiridhar@gmail.com>
date Sat, 13 Apr 2024 14:28:48 -0400
parents ee94862503e2
children 453132956401 b4c4f0d65b8a
files libinterp/corefcn/cellfun.cc libinterp/corefcn/daspk.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/dassl.cc libinterp/corefcn/kron.cc libinterp/corefcn/pr-output.cc libinterp/corefcn/schur.cc libinterp/corefcn/variables.cc
diffstat 8 files changed, 19 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/cellfun.cc	Sat Apr 13 14:23:04 2024 +0200
+++ b/libinterp/corefcn/cellfun.cc	Sat Apr 13 14:28:48 2024 -0400
@@ -1991,8 +1991,8 @@
 {
   Cell retval;
 
-  if ((nd != 1 && nd != 2) || a.ndims () != 2)
-    error ("do_mat2cell_2d: A must be two-dimensional, and ND must be 1 or 2");
+  panic_unless (nd == 1 || nd == 2);
+  panic_unless (a.ndims () == 2);
 
   if (mat2cell_mismatch (a.dims (), d, nd))
     return retval;
@@ -2049,8 +2049,7 @@
 {
   Cell retval;
 
-  if (nd < 1)
-    error ("do_mat2cell_nd: ND must be at least 1");
+  panic_unless (nd >= 1);
 
   if (mat2cell_mismatch (a.dims (), d, nd))
     return retval;
@@ -2133,8 +2132,7 @@
 {
   Cell retval;
 
-  if (nd < 1)
-    error ("do_mat2cell: ND must be at least 1");
+  panic_unless (nd >= 1);
 
   if (mat2cell_mismatch (a.dims (), d, nd))
     return retval;
--- a/libinterp/corefcn/daspk.cc	Sat Apr 13 14:23:04 2024 +0200
+++ b/libinterp/corefcn/daspk.cc	Sat Apr 13 14:28:48 2024 -0400
@@ -68,8 +68,7 @@
 {
   ColumnVector retval;
 
-  if (x.numel () != xdot.numel ())
-    error ("daspk_user_function: X and XDOT must have the same number of elements");
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -120,8 +119,7 @@
 {
   Matrix retval;
 
-  if (x.numel () != xdot.numel ())
-    error ("daspk_user_jacobian: X and XDOT must have the same number of elements");
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
--- a/libinterp/corefcn/dasrt.cc	Sat Apr 13 14:23:04 2024 +0200
+++ b/libinterp/corefcn/dasrt.cc	Sat Apr 13 14:28:48 2024 -0400
@@ -69,8 +69,7 @@
 {
   ColumnVector retval;
 
-  if (x.numel () != xdot.numel ())
-    error ("dasrt_user_f: X and XDOT must have the same number of elements");
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -160,8 +159,7 @@
 {
   Matrix retval;
 
-  if (x.numel () != xdot.numel ())
-    error ("dasrt_user_j: X and XDOT must have the same number of elements");
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
--- a/libinterp/corefcn/dassl.cc	Sat Apr 13 14:23:04 2024 +0200
+++ b/libinterp/corefcn/dassl.cc	Sat Apr 13 14:28:48 2024 -0400
@@ -67,8 +67,7 @@
 {
   ColumnVector retval;
 
-  if (x.numel () != xdot.numel ())
-    error ("dassl_user_function: X and XDOT must have the same number of elements");
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -119,8 +118,7 @@
 {
   Matrix retval;
 
-  if (x.numel () != xdot.numel ())
-    error ("dassl_user_jacobian: X and XDOT must have the same number of elements");
+  panic_unless (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
--- a/libinterp/corefcn/kron.cc	Sat Apr 13 14:23:04 2024 +0200
+++ b/libinterp/corefcn/kron.cc	Sat Apr 13 14:28:48 2024 -0400
@@ -55,8 +55,8 @@
 static MArray<T>
 kron (const MArray<R>& a, const MArray<T>& b)
 {
-  if (a.ndims () != 2 || b.ndims () != 2)
-    error ("kron: A and B must both be two-dimensional");
+  panic_unless (a.ndims () == 2);
+  panic_unless (b.ndims () == 2);
 
   octave_idx_type nra = a.rows ();
   octave_idx_type nrb = b.rows ();
@@ -86,8 +86,7 @@
 static MArray<T>
 kron (const MDiagArray2<R>& a, const MArray<T>& b)
 {
-  if (b.ndims () != 2)
-    error ("kron: B must be two-dimensional");
+  panic_unless (b.ndims () == 2);
 
   octave_idx_type nra = a.rows ();
   octave_idx_type nrb = b.rows ();
--- a/libinterp/corefcn/pr-output.cc	Sat Apr 13 14:23:04 2024 +0200
+++ b/libinterp/corefcn/pr-output.cc	Sat Apr 13 14:28:48 2024 -0400
@@ -300,8 +300,7 @@
 pr_max_internal (const MArray<T>& m)
 {
   // We expect a 2-d array.
-  if (m.ndims () != 2)
-    error ("pr_max_internal: M must be two-dimensional");
+  panic_unless (m.ndims () == 2);
 
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.columns ();
@@ -682,8 +681,7 @@
 make_matrix_format (const MT& m)
 {
   // We expect a 2-d array.
-  if (m.ndims () != 2)
-    error ("make_matrix_format: M must be two-dimensional");
+  panic_unless (m.ndims () == 2);
 
   if (free_format)
     return float_display_format ();
@@ -1572,8 +1570,7 @@
 print_empty_matrix (std::ostream& os, octave_idx_type nr, octave_idx_type nc,
                     bool pr_as_read_syntax)
 {
-  if (nr && nc)
-    error ("print_empty_matrix: at least one of NR and NC must be zero");
+  panic_unless (nr == 0 || nc == 0);
 
   if (pr_as_read_syntax)
     {
@@ -1595,8 +1592,7 @@
 print_empty_nd_array (std::ostream& os, const dim_vector& dims,
                       bool pr_as_read_syntax)
 {
-  if (! dims.any_zero ())
-    error ("print_empty_nd_array: at least one of DIMS must be zero");
+  panic_unless (dims.any_zero ());
 
   if (pr_as_read_syntax)
     os << "zeros (" << dims.str (',') << ')';
--- a/libinterp/corefcn/schur.cc	Sat Apr 13 14:23:04 2024 +0200
+++ b/libinterp/corefcn/schur.cc	Sat Apr 13 14:28:48 2024 -0400
@@ -46,9 +46,7 @@
   octave_value retval = a;
 
   octave_idx_type n = a.rows ();
-
-  if (a.columns () != n)
-    error ("mark_upper_triangular: A must be a square matrix");
+  panic_unless (a.columns () == n);
 
   const typename Matrix::element_type zero = typename Matrix::element_type ();
 
--- a/libinterp/corefcn/variables.cc	Sat Apr 13 14:23:04 2024 +0200
+++ b/libinterp/corefcn/variables.cc	Sat Apr 13 14:28:48 2024 -0400
@@ -768,8 +768,7 @@
 
   int nargin = args.length ();
 
-  if (var >= nchoices)
-    error ("set_internal_variable: VAR too large for CHOICES");
+  panic_unless (var < nchoices);
 
   if (nargout > 0 || nargin == 0)
     retval = choices[var];