@@ -514,6 +514,7 @@ computeControlLaw( dynamicgraph::Vector& control,const int& iterTime )
514
514
dynamicgraph::Matrix &V = mem->V ;
515
515
dynamicgraph::Matrix &JK = mem->JK ;
516
516
dynamicgraph::Matrix &Jt = mem->Jt ;
517
+ MemoryTaskSOT::SVD_t& svd = mem->svd ;
517
518
518
519
Jp.resize ( mJ ,nJ );
519
520
V.resize ( mJ ,mJ );
@@ -564,14 +565,20 @@ computeControlLaw( dynamicgraph::Vector& control,const int& iterTime )
564
565
/* **/ sotCOUNTER (4 ,5 ); // Jt*S
565
566
566
567
/* --- PINV --- */
567
- Eigen::MatrixXd EMPTY (0 ,0 );
568
- Eigen::dampedInverse (Jt,Jp,EMPTY,S,V,th);
568
+ svd.compute (Jt);
569
+ Eigen::dampedInverse (svd, Jp, th);
570
+ V.noalias () = svd.matrixV ();
571
+ // TODO I think variable S could be removed as it is not used when
572
+ // not recomputing the pseudo inverse.
573
+ S.noalias () = svd.singularValues ();
569
574
/* **/ sotCOUNTER (5 ,6 ); // PINV
570
575
sotDEBUG (2 ) << " V after dampedInverse." << V <<endl;
571
576
/* --- RANK --- */
572
577
{
573
- const unsigned int Jmax = S.size (); rankJ=0 ;
574
- for ( unsigned i=0 ;i<Jmax;++i ) { if ( S (i)>th ) rankJ++; }
578
+ rankJ = 0 ;
579
+ while ( rankJ < svd.singularValues ().size ()
580
+ && th < svd.singularValues ()[rankJ])
581
+ { ++rankJ; }
575
582
}
576
583
577
584
sotDEBUG (45 ) << " control" <<iterTask<<" = " <<control<<endl;
@@ -584,7 +591,7 @@ computeControlLaw( dynamicgraph::Vector& control,const int& iterTime )
584
591
// sotDEBUG(45) << "U"<<iterTask<<" = "<< U<<endl;
585
592
sotDEBUG (45 ) << " S" <<iterTask<<" = " << S<<endl;
586
593
sotDEBUG (45 ) << " V" <<iterTask<<" = " << V<<endl;
587
- sotDEBUG (45 ) << " U" <<iterTask<<" = " << EMPTY <<endl;
594
+ sotDEBUG (45 ) << " U" <<iterTask<<" = " << svd. matrixU () <<endl;
588
595
589
596
mem->jacobianInvSINOUT = Jp;
590
597
mem->jacobianInvSINOUT .setTime ( iterTime );
0 commit comments