Mercurial > forge
comparison main/fixed/src/ov-fixed-cx-mat.cc @ 9481:d84d2fea3c90 octave-forge
Re-enable compilation of fixed package
author | jordigh |
---|---|
date | Wed, 22 Feb 2012 22:07:33 +0000 |
parents | f8d77845533f |
children | 58d36e8880db |
comparison
equal
deleted
inserted
replaced
9480:954f2f00d782 | 9481:d84d2fea3c90 |
---|---|
111 { | 111 { |
112 error ("Can not resize fixed point to NDArray"); | 112 error ("Can not resize fixed point to NDArray"); |
113 return octave_value (); | 113 return octave_value (); |
114 } | 114 } |
115 FixedComplexMatrix retval (matrix); | 115 FixedComplexMatrix retval (matrix); |
116 retval.resize (dv(0), dv(1)); | 116 retval.resize (dv); |
117 return new octave_fixed_complex_matrix (retval); | 117 return new octave_fixed_complex_matrix (retval); |
118 } | 118 } |
119 | 119 |
120 FixedComplexMatrix | 120 FixedComplexMatrix |
121 octave_fixed_complex_matrix::do_index_intern (const octave_value_list& idx, | 121 octave_fixed_complex_matrix::do_index_intern (const octave_value_list& idx, |
294 // Why doesn't this work!!! Got to get it to work !!! | 294 // Why doesn't this work!!! Got to get it to work !!! |
295 if (nr == 1 && nc == 1) | 295 if (nr == 1 && nc == 1) |
296 { | 296 { |
297 FixedPointComplex c = matrix (0, 0); | 297 FixedPointComplex c = matrix (0, 0); |
298 | 298 |
299 if (::imag (c) == 0.0) | 299 if (imag (c) == 0) |
300 retval = new octave_fixed (::real (c)); | 300 retval = new octave_fixed (real (c)); |
301 else | 301 else |
302 retval = new octave_fixed_complex (c); | 302 retval = new octave_fixed_complex (c); |
303 } | 303 } |
304 else if (nr == 0 || nc == 0) | 304 else if (nr == 0 || nc == 0) |
305 retval = new octave_fixed_matrix (FixedMatrix (nr, nc)); | 305 retval = new octave_fixed_matrix (FixedMatrix (nr, nc)); |
401 | 401 |
402 return retval; | 402 return retval; |
403 } | 403 } |
404 | 404 |
405 static void | 405 static void |
406 restore_precision (void *p) | 406 restore_precision (int *p) |
407 { | 407 { |
408 bind_internal_variable ("output_precision", *(static_cast<int *> (p))); | 408 bind_internal_variable ("output_precision", *p); |
409 } | 409 } |
410 | 410 |
411 void | 411 void |
412 octave_fixed_complex_matrix::print_raw (std::ostream& os, | 412 octave_fixed_complex_matrix::print_raw (std::ostream& os, |
413 bool pr_as_read_syntax) const | 413 bool pr_as_read_syntax) const |
418 ::imag(matrix).getdecsize().row_max().max()) + | 418 ::imag(matrix).getdecsize().row_max().max()) + |
419 (min_num >= 1. ? (int)::log10(min_num) + 1 : 0); | 419 (min_num >= 1. ? (int)::log10(min_num) + 1 : 0); |
420 | 420 |
421 octave_value_list tmp = feval ("output_precision"); | 421 octave_value_list tmp = feval ("output_precision"); |
422 int prec = tmp(0).int_value (); | 422 int prec = tmp(0).int_value (); |
423 unwind_protect::add (restore_precision, &prec); | 423 |
424 unwind_protect frame; | |
425 | |
426 frame.add_fcn (restore_precision, &prec); | |
427 | |
424 bind_internal_variable ("output_precision", new_prec); | 428 bind_internal_variable ("output_precision", new_prec); |
425 | 429 |
426 octave_print_internal (os, complex_matrix_value(), false, | 430 octave_print_internal (os, complex_matrix_value(), false, |
427 current_print_indent_level ()); | 431 current_print_indent_level ()); |
428 | |
429 unwind_protect::run (); | |
430 } | 432 } |
431 | 433 |
432 bool | 434 bool |
433 octave_fixed_complex_matrix::save_ascii (std::ostream& os) | 435 octave_fixed_complex_matrix::save_ascii (std::ostream& os) |
434 { | 436 { |
592 | 594 |
593 if (error_state || ! is) | 595 if (error_state || ! is) |
594 return false; | 596 return false; |
595 | 597 |
596 // This is ugly, is there a better way? | 598 // This is ugly, is there a better way? |
597 matrix.resize (dv(0), dv(1)); | 599 matrix.resize (dim_vector (dv(0), dv(1))); |
598 for (int i = 0; i < dv(0); i++) | 600 for (int i = 0; i < dv(0); i++) |
599 for (int j = 0; j < dv(1); j++) | 601 for (int j = 0; j < dv(1); j++) |
600 matrix (i, j) = | 602 matrix (i, j) = |
601 FixedPointComplex (FixedPoint ((unsigned int)rintsize (i, j), | 603 FixedPointComplex (FixedPoint ((unsigned int)rintsize (i, j), |
602 (unsigned int)rdecsize (i, j), | 604 (unsigned int)rdecsize (i, j), |
934 H5Gclose (group_hid); | 936 H5Gclose (group_hid); |
935 if (retval < 0) | 937 if (retval < 0) |
936 return false; | 938 return false; |
937 | 939 |
938 // This is ugly, is there a better way? | 940 // This is ugly, is there a better way? |
939 matrix.resize (dv(0), dv(1)); | 941 matrix.resize (dim_vector (dv(0), dv(1))); |
940 unsigned int * ivec = intsize; | 942 unsigned int * ivec = intsize; |
941 unsigned int * dvec = decsize; | 943 unsigned int * dvec = decsize; |
942 unsigned int * nvec = number; | 944 unsigned int * nvec = number; |
943 for (int j = 0; j < dv(1); j++) | 945 for (int j = 0; j < dv(1); j++) |
944 for (int i = 0; i < dv(0); i++) | 946 for (int i = 0; i < dv(0); i++) |