intX(eye()) and sparse(eye()) fixed. 15/15215/3
Cedric Delamarre [Fri, 12 Sep 2014 12:59:55 +0000 (14:59 +0200)]
Change-Id: I8295a191fb67e4d96dda0381df3bc2220695c168

scilab/modules/ast/includes/types/int.hxx
scilab/modules/sparse/sci_gateway/cpp/sci_sparse.cpp

index a3a957d..404f3ae 100644 (file)
@@ -168,7 +168,23 @@ private :
         int iLineLen = ConfigVariable::getConsoleWidth();
         int iMaxLines = ConfigVariable::getConsoleLines();
 
-        if (ArrayOf<T>::isScalar())
+        if (isIdentity())
+        {
+            ostr << L"eye *" << std::endl << std::endl;
+            int iWidth = 0;
+            if (isSigned())
+            {
+                getSignedIntFormat(ArrayOf<T>::get(0), &iWidth);
+                addSignedIntValue(&ostr, ArrayOf<T>::get(0), iWidth);
+            }
+            else
+            {
+                getUnsignedIntFormat(ArrayOf<T>::get(0), &iWidth);
+                addUnsignedIntValue(&ostr, ArrayOf<T>::get(0), iWidth);
+            }
+            ostr << std::endl;
+        }
+        else if (ArrayOf<T>::isScalar())
         {
             //scalar
             int iWidth  = 0;
index 29d3b9a..da2c332 100644 (file)
@@ -146,6 +146,12 @@ Function::ReturnValue sci_sparse(typed_list &in, int _piRetCount, typed_list &ou
                     return types::Function::OK;
                 }
 
+                if (in[0]->getAs<Double>()->isIdentity())
+                {
+                    out.push_back(in[0]);
+                    return types::Function::OK;
+                }
+
                 pRetVal = new types::Sparse(*in[0]->getAs<Double>());
                 break;
             }