From: Stéphane MOTTELET Date: Wed, 18 Sep 2019 10:13:44 +0000 (+0200) Subject: * Bug 15781 fixed: display of complex matrix was ugly X-Git-Tag: 6.1.0~407 X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=d79ab01128a04f7776503d4f3b7a5e250a113c34 * Bug 15781 fixed: display of complex matrix was ugly https://bugzilla.scilab.org/show_bug.cgi?id=15781 This patch strictly adresses the complex display problem. Alignment is fixed and homegeneity is obtained by always displaying a real and an imaginary part even when both are zero in all cases: scalar, vector and matrix. Change-Id: I1bb92a5387bbd939d998b1ae7e9fc6df46c30528 --- diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 8df34ab..33d3866 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -162,6 +162,7 @@ Bug Fixes * [#15577](http://bugzilla.scilab.org/show_bug.cgi?id=15577): `edit` did not accept a line number as text, as with `edit linspace 21`. * [#15668](http://bugzilla.scilab.org/show_bug.cgi?id=15668): `save(filename)` saved all predefined Scilab constants %e %pi etc.. (regression) * [#15715](http://bugzilla.scilab.org/show_bug.cgi?id=15715): `%nan` indices crashed Scilab. +* [#15581](http://bugzilla.scilab.org/show_bug.cgi?id=15581): display of complex matrix was ugly. * [#15812](http://bugzilla.scilab.org/show_bug.cgi?id=15812): On assigning variables the source variable may become become corrupted * [#15840](http://bugzilla.scilab.org/show_bug.cgi?id=15840): `grand(1,"prm",m)` yielded an unsqueezed size([size(m) 1]) hypermatrix * [#15964](http://bugzilla.scilab.org/show_bug.cgi?id=15954): A complex empty sparse matrix could be obtained after insertion. diff --git a/scilab/modules/ast/includes/types/tostring_common.hxx b/scilab/modules/ast/includes/types/tostring_common.hxx index b728bc4..92cc312 100644 --- a/scilab/modules/ast/includes/types/tostring_common.hxx +++ b/scilab/modules/ast/includes/types/tostring_common.hxx @@ -21,6 +21,7 @@ #include "os_string.h" #include "dynlib_ast.h" +#define BLANK_SIZE 1 #define SIZE_BETWEEN_TWO_VALUES 1 #define SPACE_BETWEEN_TWO_VALUES L" " #define SIZE_BOOL 1 @@ -31,6 +32,7 @@ #define MINUS_STRING L"-" #define PLUS_STRING L"+" #define SYMBOL_I L"i" +#define SIZE_SYMBOL_I 1 #define MAX_LINES 100 diff --git a/scilab/modules/ast/src/cpp/types/double.cpp b/scilab/modules/ast/src/cpp/types/double.cpp index e57ba36..c6f31f2 100644 --- a/scilab/modules/ast/src/cpp/types/double.cpp +++ b/scilab/modules/ast/src/cpp/types/double.cpp @@ -1,7 +1,7 @@ /* * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab * Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS -* +* Copyright (C) 2019 - Stéphane MOTTELET * Copyright (C) 2012 - 2016 - Scilab Enterprises * * This file is hereby licensed under the terms of the GNU GPL v2.0, @@ -392,152 +392,22 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i ostr << std::endl; } } - else if (getCols() == 1) - { - //column vector - if (isComplex() == false) - { - for (int i = m_iRows1PrintState ; i < getRows() ; i++) - { - iCurrentLine++; - if ((iMaxLines == 0 && iCurrentLine >= MAX_LINES) || (iMaxLines != 0 && iCurrentLine >= iMaxLines)) - { - // Number of lines to print exceeds the max lines allowed - // Record what line we were at - m_iRows1PrintState = i; - return false; - } - - _piDims[1] = 0; - _piDims[0] = i; - int iPos = getIndex(_piDims); - - printDoubleValue(ostr, m_pRealData[iPos]); - ostr << std::endl; - } - } - else - { - for (int i = m_iRows1PrintState ; i < getRows() ; i++) - { - //complex value - iCurrentLine++; - if ((iMaxLines == 0 && iCurrentLine >= MAX_LINES) || (iMaxLines != 0 && iCurrentLine >= iMaxLines)) - { - m_iRows1PrintState = i; - return false; - } - - _piDims[1] = 0; - _piDims[0] = i; - int iPos = getIndex(_piDims); - - printComplexValue(ostr, m_pRealData[iPos], m_pImgData[iPos]); - ostr << std::endl; - } - } - } - else if (getRows() == 1) - { - //row vector - std::wostringstream ostemp; - int iLastVal = m_iCols1PrintState; - - if (isComplex() == false) - { - int iLen = 0; - for (int i = m_iCols1PrintState ; i < getCols() ; i++) - { - _piDims[0] = 0; - _piDims[1] = i; - int iPos = getIndex(_piDims); - - DoubleFormat df; - // Get the size of the column to print - getDoubleFormat(ZeroIsZero(m_pRealData[iPos]), &df); - iLen = static_cast(ostemp.str().size()) + SIZE_BETWEEN_TWO_VALUES + df.iSignLen + df.iWidth; - if (iLen >= iLineLen - 1 && iLastVal != i) - { - //Max length, new line - iCurrentLine += 4; //"column x to Y" + empty line + value + empty line - if ((iMaxLines == 0 && iCurrentLine >= MAX_LINES) || (iMaxLines != 0 && iCurrentLine >= iMaxLines)) - { - // Number of lines to print exceeds the max lines allowed - // Record what column we were at - m_iCols1PrintState = iLastVal; - return false; - } - - addColumnString(ostr, iLastVal + 1, i); - ostr << ostemp.str() << std::endl; - ostemp.str(L""); - iLastVal = i; - } - - ostemp << SPACE_BETWEEN_TWO_VALUES; - addDoubleValue(&ostemp, ZeroIsZero(m_pRealData[iPos]), &df); - } - - if (iLastVal != 0) - { - addColumnString(ostr, iLastVal + 1, getCols()); - } - ostemp << std::endl; - ostr << ostemp.str(); - } - else //complex case - { - int iTotalLen = 0; - int iLen = 0; - - for (int i = m_iCols1PrintState ; i < getCols() ; i++) - { - _piDims[0] = 0; - _piDims[1] = i; - int iPos = getIndex(_piDims); - - DoubleFormat dfR, dfI; - getComplexFormat(ZeroIsZero(m_pRealData[iPos]), ZeroIsZero(m_pImgData[iPos]), &iTotalLen, &dfR, &dfI); - iLen = static_cast(ostemp.str().size()) + SIZE_BETWEEN_TWO_VALUES + iTotalLen; - if (iLen >= iLineLen - 1 && iLastVal != i) - { - //Max length, new line - iCurrentLine += 4; //"column x to Y" + empty line + value + empty line - if ((iMaxLines == 0 && iCurrentLine >= MAX_LINES) || (iMaxLines != 0 && iCurrentLine >= iMaxLines)) - { - // Number of lines to print exceeds the max lines allowed - // Record what column we were at - m_iCols1PrintState = iLastVal; - return false; - } - - addColumnString(ostr, iLastVal + 1, i); - ostr << ostemp.str() << std::endl; - ostemp.str(L""); - iLastVal = i; - } - - ostemp << SPACE_BETWEEN_TWO_VALUES; - addDoubleComplexValue(&ostemp, ZeroIsZero(m_pRealData[iPos]), ZeroIsZero(m_pImgData[iPos]), iTotalLen, &dfR, &dfI); - } - - if (iLastVal != 0) - { - addColumnString(ostr, iLastVal + 1, getCols()); - } - ostemp << std::endl; - ostr << ostemp.str(); - } - } else // matrix { std::wostringstream ostemp; - int iLen = 0; + int iLen = SIZE_BETWEEN_TWO_VALUES; int iLastCol = m_iCols1PrintState; + // some unchanging field is to be retrieved for later used + DoubleFormat df; + int iBlankSize = df.bPrintBlank ? BLANK_SIZE : 0; //Array with the max printed size of each col int *piSize = new int[getCols()]; + int *piRSize = new int[getCols()]; + int *piISize = new int[getCols()]; memset(piSize, 0x00, getCols() * sizeof(int)); + memset(piRSize, 0x00, getCols() * sizeof(int)); + memset(piISize, 0x00, getCols() * sizeof(int)); if (isComplex() == false) { @@ -597,7 +467,7 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i ostemp << std::endl; } - iLen = 0; + iLen = SIZE_BETWEEN_TWO_VALUES; iCurrentLine++; if (m_iRows2PrintState == 0) @@ -612,7 +482,7 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i m_iCols1PrintState = 0; } - iLen += piSize[iCols1] + SIGN_LENGTH + SIZE_BETWEEN_TWO_VALUES; + iLen += piSize[iCols1] + SIZE_BETWEEN_TWO_VALUES + iBlankSize; } for (int iRows2 = m_iRows2PrintState ; iRows2 < getRows() ; iRows2++) @@ -669,13 +539,10 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i DoubleFormat dfR, dfI; getComplexFormat(ZeroIsZero(m_pRealData[iPos]), ZeroIsZero(m_pImgData[iPos]), &iTotalWidth, &dfR, &dfI); - - iTotalWidth += (dfR.iWidth == 0 ? 0 : SIGN_LENGTH) + (dfI.iWidth == 0 ? 0 : SIGN_LENGTH + 1); - if (iTotalWidth > piSize[iCols1]) - { - piSize[iCols1] = iTotalWidth; - } - + // keep track of real and imaginary part width for further alignment + piISize[iCols1] = std::max(piISize[iCols1], dfI.iWidth); + piRSize[iCols1] = std::max(piRSize[iCols1], dfR.iWidth); + piSize[iCols1] = std::max(piSize[iCols1], iTotalWidth); } } @@ -700,6 +567,8 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i m_iRows2PrintState = iRows2; m_iCols1PrintState = iLastCol; delete[] piSize; + delete[] piRSize; + delete[] piISize; return false; } @@ -713,13 +582,16 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i DoubleFormat dfR, dfI; getComplexFormat(ZeroIsZero(m_pRealData[iPos]), ZeroIsZero(m_pImgData[iPos]), &iTotalWidth, &dfR, &dfI); + // override with precomputed real part width for alignment of imaginary part sign + dfR.iWidth = piRSize[iCols2]; + dfI.iWidth = piISize[iCols2]; ostemp << SPACE_BETWEEN_TWO_VALUES; - addDoubleComplexValue(&ostemp, ZeroIsZero(m_pRealData[iPos]), ZeroIsZero(m_pImgData[iPos]), piSize[iCols2], &dfR, &dfI); + addDoubleComplexValue(&ostemp, ZeroIsZero(m_pRealData[iPos]), ZeroIsZero(m_pImgData[iPos]), piSize[iCols2], &dfR, &dfI); } ostemp << std::endl; } - iLen = 0; + iLen = SIZE_BETWEEN_TWO_VALUES; iCurrentLine++; if (m_iRows2PrintState == 0) @@ -752,6 +624,7 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i m_iRows2PrintState = iRows2; m_iCols1PrintState = iLastCol; delete[] piSize; + delete[] piRSize; return false; } @@ -765,8 +638,11 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i DoubleFormat dfR, dfI; getComplexFormat(ZeroIsZero(m_pRealData[iPos]), ZeroIsZero(m_pImgData[iPos]), &iTotalWidth, &dfR, &dfI); + // override with precomputed real part width for aligment of imaginary part sign + dfR.iWidth = piRSize[iCols2]; + dfI.iWidth = piISize[iCols2]; ostemp << SPACE_BETWEEN_TWO_VALUES; - addDoubleComplexValue(&ostemp, ZeroIsZero(m_pRealData[iPos]), ZeroIsZero(m_pImgData[iPos]), piSize[iCols2], &dfR, &dfI); + addDoubleComplexValue(&ostemp, ZeroIsZero(m_pRealData[iPos]), ZeroIsZero(m_pImgData[iPos]), piSize[iCols2], &dfR, &dfI); } ostemp << std::endl; } @@ -779,6 +655,8 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i } delete[] piSize; + delete[] piRSize; + delete[] piISize; } return true; diff --git a/scilab/modules/ast/src/cpp/types/tostring_common.cpp b/scilab/modules/ast/src/cpp/types/tostring_common.cpp index 1084e74..0badf9e 100644 --- a/scilab/modules/ast/src/cpp/types/tostring_common.cpp +++ b/scilab/modules/ast/src/cpp/types/tostring_common.cpp @@ -1,7 +1,7 @@ /* * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab * Copyright (C) 2009 - DIGITEO - Antoine ELIAS -* Copyright (C) 2018 - Stéphane MOTTELET +* Copyright (C) 2018 - 2019 - Stéphane MOTTELET * * Copyright (C) 2012 - 2016 - Scilab Enterprises * @@ -28,10 +28,8 @@ extern "C" #include "os_string.h" #include "dtoa.h" #include "charEncoding.h" -#include "sciprint.h" } -#define BLANK_SIZE 1 #define POINT_SIZE 1 #define EXPOSANT_SIZE 2 //exposant symbol + exposant sign @@ -182,38 +180,8 @@ void getComplexFormat(double _dblR, double _dblI, int *_piTotalWidth, DoubleForm { getDoubleFormat(_dblR, _pDFR); getDoubleFormat(_dblI, _pDFI); - - *_piTotalWidth = 0; - if (isRealZero(_dblI)) - { - if (isRealZero(_dblR)) - { - *_piTotalWidth += 1; //"0" - _pDFI->iWidth = 0; - _pDFI->iSignLen = 0; - } - else - { - *_piTotalWidth += _pDFR->iWidth; - _pDFI->iWidth = 0; - _pDFI->iSignLen = 0; - } - } - else - { - if (isRealZero(_dblR)) - { - *_piTotalWidth += _pDFI->iWidth; - _pDFR->iWidth = 0; - } - else - { - *_piTotalWidth += _pDFR->iWidth + _pDFI->iWidth; - } - - // i character - *_piTotalWidth += 1; - } + + *_piTotalWidth = _pDFR->iWidth + _pDFI->iWidth + 2*(_pDFR->bPrintBlank ? BLANK_SIZE : 0) + BLANK_SIZE + SIZE_SYMBOL_I; } void addDoubleValue(std::wostringstream * _postr, double _dblVal, DoubleFormat * _pDF) @@ -331,16 +299,16 @@ void addDoubleValue(std::wostringstream * _postr, double _dblVal, DoubleFormat * { if (_pDF->bPrintPoint) { - /* str.append(std::max(0, (ConfigVariable::getFormatSize() - (int)str.length()))-1, '0'); */ + /*str.append(std::max(0, (ConfigVariable::getFormatSize() - (int)str.length()))-1, '0');*/ } else { - iWidth = 1+str.length(); + iWidth = 1 + str.length(); } } wchar_t* pwstData = to_wide_string(str.data()); - os_swprintf(pwstOutput, 32, L"%ls%-*ls", pwstSign, iWidth-1, pwstData); + os_swprintf(pwstOutput, 32, L"%ls%-*ls", pwstSign, iWidth - 1, pwstData); FREE(pwstData); } else if (wcslen(pwstSign) != 0) @@ -375,80 +343,36 @@ void addDoubleComplexValue(std::wostringstream * _postr, double _dblR, double _d */ // *_postr << "|%" << _iTotalWitdh << "%|"; - if (_dblR == 0) - { - //no real part - if (_dblI == 0) - { - //no imaginary part - //0 - DoubleFormat df; + //R + DoubleFormat df; - addDoubleValue(&ostemp, 0, &df); - } - else - { - //imaginary part - - //I - DoubleFormat df; - - df.iWidth = 0; - df.iPrec = _pDFI->iPrec; - df.bExp = _pDFI->bExp; - df.bPrintPlusSign = false; - df.bPrintOne = false; - addDoubleValue(&ostemp, _dblI, &df); - ostemp << std::left << SYMBOL_I; - if (_dblI == 1) - { - addSpaces(&ostemp, 1); - } + df.iPrec = _pDFR->iPrec; + df.bExp = _pDFR->bExp; - } + if (ISNAN(_dblR) || !finite(_dblR)) + { + ostemp << std::left << std::setw(_pDFR->iWidth + 1); + addDoubleValue(&ostemp, _dblR, &df); } else { - //real part - if (_dblI == 0) - { - //no imaginary part - - //R - DoubleFormat df; - - df.iWidth = 0; - df.iPrec = _pDFR->iPrec; - df.bExp = _pDFR->bExp; - addDoubleValue(&ostemp, _dblR, &df); - } - else - { - //imaginary part - - //R - DoubleFormat df; - - df.iPrec = _pDFR->iPrec; - df.bExp = _pDFR->bExp; - - addDoubleValue(&ostemp, _dblR, &df); - - //I - df.iPrec = _pDFI->iPrec; - df.bExp = _pDFI->bExp; - df.bPrintPlusSign = true; - df.bPrintComplexPlusSpace = true; - df.bPrintOne = false; - - addDoubleValue(&ostemp, _dblI, &df); - ostemp << std::left << SYMBOL_I; - if (_dblI == 1) - { - addSpaces(&ostemp, 2); - } - } + // following line allows to align sign of imaginary part + addDoubleValue(&ostemp, _dblR, &df); + addSpaces(&ostemp, _pDFR->iWidth - ostemp.tellp() + 1); + } + //I + df.iPrec = _pDFI->iPrec; + df.bExp = _pDFI->bExp; + df.bPrintPlusSign = true; + df.bPrintComplexPlusSpace = true; + df.bPrintOne = false; + + addDoubleValue(&ostemp, _dblI, &df); + ostemp << std::left << SYMBOL_I; + if (_dblI == 1 && _pDFI->bExp == false) + { + addSpaces(&ostemp, 2); } configureStream(_postr, _iTotalWidth, 0, ' '); @@ -507,8 +431,8 @@ void printDoubleValue(std::wostringstream& ostr, double val) void printComplexValue(std::wostringstream& ostr, double val_r, double val_i) { DoubleFormat dfR, dfI; - getDoubleFormat(ZeroIsZero(val_r), &dfR); - getDoubleFormat(ZeroIsZero(val_i), &dfI); + int iTotalWidth; + getComplexFormat(ZeroIsZero(val_r), ZeroIsZero(val_i), &iTotalWidth, &dfR, &dfI); ostr << SPACE_BETWEEN_TWO_VALUES; - addDoubleComplexValue(&ostr, ZeroIsZero(val_r), ZeroIsZero(val_i), dfR.iWidth + dfI.iWidth, &dfR, &dfI); + addDoubleComplexValue(&ostr, ZeroIsZero(val_r), ZeroIsZero(val_i), iTotalWidth, &dfR, &dfI); } diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_15781.dia.ref b/scilab/modules/ast/tests/nonreg_tests/bug_15781.dia.ref new file mode 100644 index 0000000..97eecbe --- /dev/null +++ b/scilab/modules/ast/tests/nonreg_tests/bug_15781.dia.ref @@ -0,0 +1,172 @@ +// Copyright (C) 2019 - Stéphane MOTTELET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 15781 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/15781 +// +// <-- Short Description --> +// display of complex matrix is ugly. +n=4 + n = + 4. +a=testmatrix("magic",4); +for f = ["v","e"] + format(f) + x=complex(cos(a),sin(a)); + x(3,3)=%nan; + x(4,4)=%inf; + x(2,1:2)=1+%i; + x(:,1)=0; + disp(x) + for i=1:n + disp(x(i,:)) + disp(" ") + end + for i=1:n + disp(x(:,i)) + disp(" ") + end + x=x-x; + disp(x) + disp(" ") + acoth(-2:0.5:2).' +end + column 1 to 3 + 0. + 0.i -0.4161468 + 0.9092974i -0.9899925 + 0.14112i + 0. + 0.i 1. + i -0.8390715 - 0.5440211i + 0. + 0.i 0.7539023 + 0.6569866i Nan + 0.i + 0. + 0.i 0.1367372 + 0.9906074i -0.7596879 + 0.6502878i + column 4 + 0.9074468 + 0.420167i + -0.1455 + 0.9893582i + 0.843854 - 0.5365729i + Inf + 0.i + column 1 to 3 + 0. + 0.i -0.4161468 + 0.9092974i -0.9899925 + 0.14112i + column 4 + 0.9074468 + 0.420167i + + 0. + 0.i 1. + i -0.8390715 - 0.5440211i -0.1455 + 0.9893582i + + column 1 to 3 + 0. + 0.i 0.7539023 + 0.6569866i Nan + 0.i + column 4 + 0.843854 - 0.5365729i + + column 1 to 3 + 0. + 0.i 0.1367372 + 0.9906074i -0.7596879 + 0.6502878i + column 4 + Inf + 0.i + + 0. + 0.i + 0. + 0.i + 0. + 0.i + 0. + 0.i + + -0.4161468 + 0.9092974i + 1. + i + 0.7539023 + 0.6569866i + 0.1367372 + 0.9906074i + + -0.9899925 + 0.14112i + -0.8390715 - 0.5440211i + Nan + 0.i + -0.7596879 + 0.6502878i + + 0.9074468 + 0.420167i + -0.1455 + 0.9893582i + 0.843854 - 0.5365729i + Inf + 0.i + + 0. + 0.i 0. + 0.i 0. + 0.i 0. + 0.i + 0. + 0.i 0. + 0.i 0. + 0.i 0. + 0.i + 0. + 0.i 0. + 0.i Nan + 0.i 0. + 0.i + 0. + 0.i 0. + 0.i 0. + 0.i Nan + 0.i + + ans = + -0.5493061 + 0.i + -0.804719 + 0.i + -Inf - 0.7853982i + -0.5493061 - 1.5707963i + 0. - 1.5707963i + 0.5493061 - 1.5707963i + Inf + Nani + 0.804719 + 3.1415927i + 0.5493061 + 3.1415927i + column 1 to 2 + 0.000D+00 + 0.000D+00i -4.161D-01 + 9.093D-01i + 0.000D+00 + 0.000D+00i 1.000D+00 + 1.000D+00i + 0.000D+00 + 0.000D+00i 7.539D-01 + 6.570D-01i + 0.000D+00 + 0.000D+00i 1.367D-01 + 9.906D-01i + column 3 to 4 + -9.900D-01 + 1.411D-01i 9.074D-01 + 4.202D-01i + -8.391D-01 - 5.440D-01i -1.455D-01 + 9.894D-01i + Nan + 0.000D+00i 8.439D-01 - 5.366D-01i + -7.597D-01 + 6.503D-01i Inf + 0.000D+00i + column 1 to 2 + 0.000D+00 + 0.000D+00i -4.161D-01 + 9.093D-01i + column 3 to 4 + -9.900D-01 + 1.411D-01i 9.074D-01 + 4.202D-01i + + column 1 to 2 + 0.000D+00 + 0.000D+00i 1.000D+00 + 1.000D+00i + column 3 to 4 + -8.391D-01 - 5.440D-01i -1.455D-01 + 9.894D-01i + + column 1 to 3 + 0.000D+00 + 0.000D+00i 7.539D-01 + 6.570D-01i Nan + 0.000D+00i + column 4 + 8.439D-01 - 5.366D-01i + + column 1 to 2 + 0.000D+00 + 0.000D+00i 1.367D-01 + 9.906D-01i + column 3 to 4 + -7.597D-01 + 6.503D-01i Inf + 0.000D+00i + + 0.000D+00 + 0.000D+00i + 0.000D+00 + 0.000D+00i + 0.000D+00 + 0.000D+00i + 0.000D+00 + 0.000D+00i + + -4.161D-01 + 9.093D-01i + 1.000D+00 + 1.000D+00i + 7.539D-01 + 6.570D-01i + 1.367D-01 + 9.906D-01i + + -9.900D-01 + 1.411D-01i + -8.391D-01 - 5.440D-01i + Nan + 0.000D+00i + -7.597D-01 + 6.503D-01i + + 9.074D-01 + 4.202D-01i + -1.455D-01 + 9.894D-01i + 8.439D-01 - 5.366D-01i + Inf + 0.000D+00i + + column 1 to 2 + 0.000D+00 + 0.000D+00i 0.000D+00 + 0.000D+00i + 0.000D+00 + 0.000D+00i 0.000D+00 + 0.000D+00i + 0.000D+00 + 0.000D+00i 0.000D+00 + 0.000D+00i + 0.000D+00 + 0.000D+00i 0.000D+00 + 0.000D+00i + column 3 to 4 + 0.000D+00 + 0.000D+00i 0.000D+00 + 0.000D+00i + 0.000D+00 + 0.000D+00i 0.000D+00 + 0.000D+00i + Nan + 0.000D+00i 0.000D+00 + 0.000D+00i + 0.000D+00 + 0.000D+00i Nan + 0.000D+00i + + ans = + -5.493D-01 + 0.000D+00i + -8.047D-01 + 0.000D+00i + -Inf - 7.854D-01i + -5.493D-01 - 1.571D+00i + 0.000D+00 - 1.571D+00i + 5.493D-01 - 1.571D+00i + Inf + Nani + 8.047D-01 + 3.142D+00i + 5.493D-01 + 3.142D+00i diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_15781.tst b/scilab/modules/ast/tests/nonreg_tests/bug_15781.tst new file mode 100644 index 0000000..281972f --- /dev/null +++ b/scilab/modules/ast/tests/nonreg_tests/bug_15781.tst @@ -0,0 +1,45 @@ +// Copyright (C) 2019 - Stéphane MOTTELET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 15781 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/15781 +// +// <-- Short Description --> +// display of complex matrix is ugly. + +n=4 + +a=testmatrix("magic",4); + +for f = ["v","e"] + format(f) + x=complex(cos(a),sin(a)); + x(3,3)=%nan; + x(4,4)=%inf; + x(2,1:2)=1+%i; + x(:,1)=0; + disp(x) + + for i=1:n + disp(x(i,:)) + disp(" ") + end + + for i=1:n + disp(x(:,i)) + disp(" ") + end + + x=x-x; + + disp(x) + disp(" ") + + acoth(-2:0.5:2).' +end