comparison src/utils.cc @ 4478:7afd4bf05aa8

[project @ 2003-07-30 19:15:31 by jwe]
author jwe
date Wed, 30 Jul 2003 19:15:31 +0000
parents d7d9ca19960a
children cfbaee1f562f
comparison
equal deleted inserted replaced
4477:87c2e107f811 4478:7afd4bf05aa8
227 // should be considered fatal; return 1 if this is ok. 227 // should be considered fatal; return 1 if this is ok.
228 228
229 int 229 int
230 empty_arg (const char *name, int nr, int nc) 230 empty_arg (const char *name, int nr, int nc)
231 { 231 {
232 int is_empty = 0; 232 return (nr == 0 || nc == 0);
233
234 if (nr == 0 || nc == 0)
235 {
236 int flag = Vpropagate_empty_matrices;
237
238 if (flag < 0)
239 {
240 gripe_empty_arg (name, 0);
241 is_empty = 1;
242 }
243 else if (flag == 0)
244 {
245 gripe_empty_arg (name, 1);
246 is_empty = -1;
247 }
248 else
249 is_empty = 1;
250 }
251
252 return is_empty;
253 } 233 }
254 234
255 // See if the given file is in the path. 235 // See if the given file is in the path.
256 236
257 std::string 237 std::string
826 error ("%s: expecting two scalar arguments", warn_for); 806 error ("%s: expecting two scalar arguments", warn_for);
827 else 807 else
828 check_dimensions (nr, nc, warn_for); // May set error_state. 808 check_dimensions (nr, nc, warn_for); // May set error_state.
829 } 809 }
830 810
811 Matrix
812 identity_matrix (int nr, int nc)
813 {
814 Matrix m (nr, nc, 0.0);
815
816 if (nr > 0 && nc > 0)
817 {
818 int n = std::min (nr, nc);
819
820 for (int i = 0; i < n; i++)
821 m (i, i) = 1.0;
822 }
823
824 return m;
825 }
826
831 extern int 827 extern int
832 octave_format (std::ostream& os, const char *fmt, ...) 828 octave_format (std::ostream& os, const char *fmt, ...)
833 { 829 {
834 int retval = -1; 830 int retval = -1;
835 831