getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] r4996 - /trunk/getfem/src/getfem_plasticity.cc


From: logari81
Subject: [Getfem-commits] r4996 - /trunk/getfem/src/getfem_plasticity.cc
Date: Thu, 21 May 2015 10:49:05 -0000

Author: logari81
Date: Thu May 21 12:49:04 2015
New Revision: 4996

URL: http://svn.gna.org/viewcvs/getfem?rev=4996&view=rev
Log:
new implementation of the derivative of logm

Modified:
    trunk/getfem/src/getfem_plasticity.cc

Modified: trunk/getfem/src/getfem_plasticity.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_plasticity.cc?rev=4996&r1=4995&r2=4996&view=diff
==============================================================================
--- trunk/getfem/src/getfem_plasticity.cc       (original)
+++ trunk/getfem/src/getfem_plasticity.cc       Thu May 21 12:49:04 2015
@@ -805,6 +805,9 @@
     return true;
   }
 
+  // numerical differantiation of logm
+  // not used becaused it caused some issues and was slower than
+  // simply inverting the derivative of expm
   bool logm_deriv(const base_matrix &a, base_tensor &dalog,
                   base_matrix *palog=NULL) {
 
@@ -887,9 +890,16 @@
     void derivative(const arg_list &args, size_type /*nder*/,
                     base_tensor &result) const {
       size_type N = args[0]->sizes()[0];
-      base_matrix inpmat(N,N);
+      base_matrix inpmat(N,N), outmat(N,N), tmpmat(N*N,N*N);
       gmm::copy(args[0]->as_vector(), inpmat.as_vector());
-      bool info = logm_deriv(inpmat, result);
+      gmm::logm(inpmat, outmat);
+      bool info = expm_deriv(outmat, result);
+      if (info) {
+        gmm::copy(result.as_vector(), tmpmat.as_vector());
+        scalar_type det = gmm::lu_inverse(tmpmat);
+        if (det <= 0) gmm::copy(gmm::identity_matrix(), tmpmat);
+        gmm::copy(tmpmat.as_vector(), result.as_vector());
+      }
       GMM_ASSERT1(info, "Matrix logarithm derivative calculation "
                         "failed to converge");
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]