Salome HOME
Missing wrap of appendFieldProfileFlatly
[tools/medcoupling.git] / src / INTERP_KERNEL / InterpKernelMatrixTools.cxx
index ada00883dfdc863d8ca2bf00eb9d36d3461dede6..cc1c08130c03bf4e297a8486173272a681fd7382 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // Author : Anthony Geay (CEA/DEN)
 
 #include "InterpKernelMatrixTools.hxx"
+#include "InterpKernelException.hxx"
 #include "InterpKernelAutoPtr.hxx"
 
+#include <sstream>
 #include <algorithm>
 
 namespace INTERP_KERNEL
@@ -299,12 +301,12 @@ namespace INTERP_KERNEL
     for(int k=0;k<n-1;k++)
       {
         //  Find L=pivot index.
-        l=idamax(n-k-1,a+k+k*lda,1)+k;
+        l=idamax(n-k,a+k+k*lda,1)+k;
         ipvt[k]=l;
         // Zero pivot implies this column already triangularized.
         if(a[l+k*lda]==0.0)
           {
-            info=k+1;
+            info=k;
             continue;
           }
         //Interchange if necessary.
@@ -321,7 +323,7 @@ namespace INTERP_KERNEL
         for(int j=k+1;j<n;j++)
           {
             t=a[l+j*lda];
-            if(l!=k-1)
+            if(l!=k)
               {
                 a[l+j*lda]=a[k+j*lda];
                 a[k+j*lda]=t;
@@ -396,6 +398,11 @@ namespace INTERP_KERNEL
 
   void matrixProduct(const double *A, int n1, int p1, const double *B, int n2, int p2, double *C)
   {
+    if(p1!=n2)
+      {
+        std::ostringstream oss; oss << "matrixProduct : the size of input matrix are not coherent the nb of cols of input matrix #0 is " <<  p1 << " whereas the number of rows of input matrix #1 is " << n2 << " !";
+        throw INTERP_KERNEL::Exception(oss.str().c_str());
+      }
     for(int i=0;i<n1;i++)
       {
         for(int j=0;j<p2;j++)