Mercurial > octave
comparison libinterp/corefcn/kron.cc @ 33389:c714266d9f0d
Replace some `panic_unless` with `error` for input validation
Some instances of `panic_unless` were being used to validate function inputs.
This patch changes many of those instances to `error ()` with a more detailed
error message than before.
Files affected: cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, kron.cc,
pr-output.cc, schur.cc, variables.cc
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Fri, 12 Apr 2024 18:53:59 -0400 |
parents | 40fde86be9b0 |
children | a258493e726a |
comparison
equal
deleted
inserted
replaced
33387:4bb532314db1 | 33389:c714266d9f0d |
---|---|
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 panic_unless (a.ndims () == 2); | 58 if (a.ndims () != 2 || b.ndims () != 2) |
59 panic_unless (b.ndims () == 2); | 59 error ("kron: A and B must both be two-dimensional"); |
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 panic_unless (b.ndims () == 2); | 89 if (b.ndims () != 2) |
90 error ("kron: B must be two-dimensional"); | |
90 | 91 |
91 octave_idx_type nra = a.rows (); | 92 octave_idx_type nra = a.rows (); |
92 octave_idx_type nrb = b.rows (); | 93 octave_idx_type nrb = b.rows (); |
93 octave_idx_type dla = a.diag_length (); | 94 octave_idx_type dla = a.diag_length (); |
94 octave_idx_type nca = a.cols (); | 95 octave_idx_type nca = a.cols (); |