Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IValue Matrix ToString() #5

Closed
GoogleCodeExporter opened this issue Mar 22, 2015 · 2 comments
Closed

IValue Matrix ToString() #5

GoogleCodeExporter opened this issue Mar 22, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

When creating a string representation of a matrix, with the following code in 
mpIValue.cpp

  string_type IValue::ToString() const
  {
    stringstream_type ss;
    switch (GetType())
    {
    case 'm':  
          {
            const matrix_type &arr(GetArray());

           // if (arr.GetRows()>1)
              ss << _T("{");

            for (int i=0; i<arr.GetRows(); ++i)
            {
              if (arr.GetCols()>1)
                ss << _T("{");

              for (int j=0; j<arr.GetCols();++j)
              {
                ss << arr.At(i, j).ToString();
                if (j!=arr.GetCols()-1)
                  ss << _T(", ");
              }

              if (arr.GetCols()>1)
                ss << _T("}");

              if (i!=arr.GetRows()-1)
                ss << _T("; ");
            }

            // if (arr.GetRows()>1)
              ss << _T("} ");
          }
          break;


I wonder if it would be better to not test for 
"if (arr.GetRows()>1)" at the start and end of the string build (I have 
commented the two lines above).

Right now the output for a matrix of 1 value is just

value

however I think it should be 

{value}

even if the matrix has only one value, in order to make a difference with the 
non-matrix 

value


Original issue reported on code.google.com by ssecm...@gmail.com on 13 Feb 2012 at 11:10

@GoogleCodeExporter
Copy link
Author

This was done deliberately because the engine should automatically unbox a 
matrix if it contains only a single element. Internally plain nonmatrix values 
should be treated like a 1x1 matrix. From the outside you shoudnt see a 
difference between a 1x1 matrix and a plain value.

Original comment by ib...@gmx.info on 16 Feb 2012 at 9:18

@GoogleCodeExporter
Copy link
Author

Original comment by ib...@gmx.info on 19 Feb 2012 at 8:48

  • Changed state: WontFix
  • Added labels: Type-Other
  • Removed labels: Type-Defect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant