Lines 94-123
Link Here
|
94 |
octave_fixed_complex_matrix::array_value (bool force_conversion) const |
94 |
octave_fixed_complex_matrix::array_value (bool force_conversion) const |
95 |
{ |
95 |
{ |
96 |
NDArray retval; |
96 |
NDArray retval; |
97 |
int flag = force_conversion; |
|
|
98 |
|
97 |
|
99 |
#if defined(HAVE_OK_TO_LOSE_IMAGINARY_PART) |
98 |
if (! force_conversion) |
100 |
if (! flag) |
|
|
101 |
flag = Vok_to_lose_imaginary_part; |
102 |
#else |
103 |
if (! flag) |
104 |
flag = (Vwarn_imag_to_real ? -1 : 1); |
105 |
#endif |
106 |
|
107 |
if (flag > 0) |
108 |
{ |
109 |
int nr = rows (); |
110 |
int nc = columns (); |
111 |
dim_vector dv(nr,nc); |
112 |
retval.resize (dv); |
113 |
|
114 |
for (int i=0; i<nr; i++) |
115 |
for (int j=0; j<nc; j++) |
116 |
retval(i + j*nr) = real (matrix(i,j).fixedpoint()); |
117 |
} |
118 |
else |
119 |
gripe_implicit_conversion ("fixed complex", "matrix"); |
99 |
gripe_implicit_conversion ("fixed complex", "matrix"); |
120 |
|
100 |
|
|
|
101 |
int nr = rows (); |
102 |
int nc = columns (); |
103 |
dim_vector dv(nr,nc); |
104 |
retval.resize (dv); |
105 |
|
106 |
for (int i=0; i<nr; i++) |
107 |
for (int j=0; j<nc; j++) |
108 |
retval(i + j*nr) = real (matrix(i,j).fixedpoint()); |
109 |
|
121 |
return retval; |
110 |
return retval; |
122 |
} |
111 |
} |
123 |
|
112 |
|
Lines 349-385
Link Here
|
349 |
{ |
338 |
{ |
350 |
double retval = lo_ieee_nan_value (); |
339 |
double retval = lo_ieee_nan_value (); |
351 |
|
340 |
|
352 |
int flag = force_conversion; |
341 |
if (! force_conversion) |
353 |
|
|
|
354 |
#if defined(HAVE_OK_TO_LOSE_IMAGINARY_PART) |
355 |
if (! flag) |
356 |
flag = Vok_to_lose_imaginary_part; |
357 |
#else |
358 |
if (! flag) |
359 |
flag = (Vwarn_imag_to_real ? -1 : 1); |
360 |
#endif |
361 |
|
362 |
if (flag < 0) |
363 |
gripe_implicit_conversion ("fixed complex matrix", "real scalar"); |
342 |
gripe_implicit_conversion ("fixed complex matrix", "real scalar"); |
364 |
|
343 |
|
365 |
if (flag) |
344 |
if (rows () > 0 && columns () > 0) |
366 |
{ |
345 |
{ |
367 |
|
346 |
gripe_implicit_conversion ("real matrix", "real scalar"); |
368 |
#if defined(HAVE_DO_FORTRAN_INDEXING) |
|
|
369 |
if ((rows () == 1 && columns () == 1) |
370 |
|| (Vdo_fortran_indexing && rows () > 0 && columns () > 0)) |
371 |
retval = std::real (matrix (0, 0) .fixedpoint()); |
372 |
#else |
373 |
if (rows () > 0 && columns () > 0) |
374 |
{ |
375 |
if (Vwarn_fortran_indexing) |
376 |
gripe_implicit_conversion ("real matrix", "real scalar"); |
377 |
|
347 |
|
378 |
retval = std::real (matrix (0, 0) .fixedpoint()); |
348 |
retval = std::real (matrix (0, 0) .fixedpoint()); |
379 |
} |
|
|
380 |
#endif |
381 |
else |
382 |
gripe_invalid_conversion ("fixed complex matrix", "real scalar"); |
383 |
} |
349 |
} |
384 |
else |
350 |
else |
385 |
gripe_invalid_conversion ("fixed complex matrix", "real scalar"); |
351 |
gripe_invalid_conversion ("fixed complex matrix", "real scalar"); |
Lines 392-427
Link Here
|
392 |
{ |
358 |
{ |
393 |
FixedPoint retval; |
359 |
FixedPoint retval; |
394 |
|
360 |
|
395 |
int flag = force_conversion; |
361 |
if (! force_conversion) |
396 |
|
|
|
397 |
#if defined(HAVE_OK_TO_LOSE_IMAGINARY_PART) |
398 |
if (! flag) |
399 |
flag = Vok_to_lose_imaginary_part; |
400 |
#else |
401 |
if (! flag) |
402 |
flag = (Vwarn_imag_to_real ? -1 : 1); |
403 |
#endif |
404 |
|
405 |
if (flag < 0) |
406 |
gripe_implicit_conversion ("fixed complex matrix", "fixed scalar"); |
362 |
gripe_implicit_conversion ("fixed complex matrix", "fixed scalar"); |
407 |
|
363 |
|
408 |
if (flag) |
364 |
if (rows () > 0 && columns () > 0) |
409 |
{ |
365 |
{ |
410 |
#if defined(HAVE_DO_FORTRAN_INDEXING) |
366 |
gripe_implicit_conversion ("real matrix", "real scalar"); |
411 |
if ((rows () == 1 && columns () == 1) |
367 |
|
412 |
|| (Vdo_fortran_indexing && rows () > 0 && columns () > 0)) |
368 |
retval = real( matrix (0, 0)); |
413 |
retval = real( matrix (0, 0)); |
|
|
414 |
#else |
415 |
if (rows () > 0 && columns () > 0) |
416 |
{ |
417 |
if (Vwarn_fortran_indexing) |
418 |
gripe_implicit_conversion ("real matrix", "real scalar"); |
419 |
|
420 |
retval = real( matrix (0, 0)); |
421 |
} |
422 |
#endif |
423 |
else |
424 |
gripe_invalid_conversion ("fixed complex matrix", "fixed scalar"); |
425 |
} |
369 |
} |
426 |
else |
370 |
else |
427 |
gripe_invalid_conversion ("fixed complex matrix", "fixed scalar"); |
371 |
gripe_invalid_conversion ("fixed complex matrix", "fixed scalar"); |
Lines 434-456
Link Here
|
434 |
{ |
378 |
{ |
435 |
Matrix retval; |
379 |
Matrix retval; |
436 |
|
380 |
|
437 |
int flag = force_conversion; |
381 |
if (! force_conversion) |
438 |
|
|
|
439 |
#if defined(HAVE_OK_TO_LOSE_IMAGINARY_PART) |
440 |
if (! flag) |
441 |
flag = Vok_to_lose_imaginary_part; |
442 |
#else |
443 |
if (! flag) |
444 |
flag = (Vwarn_imag_to_real ? -1 : 1); |
445 |
#endif |
446 |
|
447 |
if (flag < 0) |
448 |
gripe_implicit_conversion ("fixed complex matrix", "real matrix"); |
382 |
gripe_implicit_conversion ("fixed complex matrix", "real matrix"); |
449 |
|
383 |
|
450 |
if (flag) |
384 |
|
451 |
retval = ::real (matrix.fixedpoint()); |
385 |
retval = ::real (matrix.fixedpoint()); |
452 |
else |
|
|
453 |
gripe_invalid_conversion ("fixed complex matrix", "real matrix"); |
454 |
|
386 |
|
455 |
return retval; |
387 |
return retval; |
456 |
} |
388 |
} |
Lines 460-482
Link Here
|
460 |
{ |
392 |
{ |
461 |
FixedMatrix retval; |
393 |
FixedMatrix retval; |
462 |
|
394 |
|
463 |
int flag = force_conversion; |
395 |
if (! force_conversion) |
464 |
|
|
|
465 |
#if defined(HAVE_OK_TO_LOSE_IMAGINARY_PART) |
466 |
if (! flag) |
467 |
flag = Vok_to_lose_imaginary_part; |
468 |
#else |
469 |
if (! flag) |
470 |
flag = (Vwarn_imag_to_real ? -1 : 1); |
471 |
#endif |
472 |
|
473 |
if (flag < 0) |
474 |
gripe_implicit_conversion ("fixed complex matrix", "fixed matrix"); |
396 |
gripe_implicit_conversion ("fixed complex matrix", "fixed matrix"); |
475 |
|
397 |
|
476 |
if (flag) |
398 |
retval = real (matrix); |
477 |
retval = real (matrix); |
|
|
478 |
else |
479 |
gripe_invalid_conversion ("fixed complex matrix", "fixed matrix"); |
480 |
|
399 |
|
481 |
return retval; |
400 |
return retval; |
482 |
} |
401 |
} |
Lines 488-506
Link Here
|
488 |
|
407 |
|
489 |
Complex retval (tmp, tmp); |
408 |
Complex retval (tmp, tmp); |
490 |
|
409 |
|
491 |
#if defined(HAVE_DO_FORTRAN_INDEXING) |
410 |
if (rows () > 0 && columns () > 0) |
492 |
if ((rows () == 1 && columns () == 1) |
411 |
{ |
493 |
|| (Vdo_fortran_indexing && rows () > 0 && columns () > 0)) |
412 |
gripe_implicit_conversion ("real matrix", "real scalar"); |
494 |
retval = matrix (0, 0) .fixedpoint(); |
|
|
495 |
#else |
496 |
if (rows () > 0 && columns () > 0) |
497 |
{ |
498 |
if (Vwarn_fortran_indexing) |
499 |
gripe_implicit_conversion ("real matrix", "real scalar"); |
500 |
|
413 |
|
501 |
retval = matrix (0, 0) .fixedpoint(); |
414 |
retval = matrix (0, 0) .fixedpoint(); |
502 |
} |
415 |
} |
503 |
#endif |
|
|
504 |
else |
416 |
else |
505 |
gripe_invalid_conversion ("fixed matrix", "complex scalar"); |
417 |
gripe_invalid_conversion ("fixed matrix", "complex scalar"); |
506 |
|
418 |
|