@@ -627,34 +627,6 @@ computeControlLaw( dynamicgraph::Vector& control,const int& iterTime )
627
627
if ( 0 ==iterTask )
628
628
{ Proj.resize ( mJ ,mJ ); Proj.setIdentity (); }
629
629
630
- // {
631
- // double *p,*v1,*v2,*vtmp1,*vtmp2;
632
- // p = traits::matrix_storage(Proj.matrix);
633
- // v1 = traits::matrix_storage(V.matrix);
634
- // v2 = traits::matrix_storage(V.matrix);
635
- // vtmp1 = traits::matrix_storage(V.matrix);
636
- // /***/sotCOUNTER(6,7); // Ppre
637
-
638
- // for( unsigned int i=0;i<mJ;++i )
639
- // {
640
- // vtmp2 = traits::matrix_storage(V.matrix);
641
- // for( unsigned int j=0;j<mJ;++j )
642
- // {
643
- // v1 = vtmp1; v2 = vtmp2;
644
- // for( unsigned int k=0;k<rankJ;++k )
645
- // {
646
- // (*p) -=( *v1) * (*v2);
647
- // v2++;v1++;
648
- // }
649
- // p++; vtmp2 += mJ;
650
- // }
651
- // vtmp1 += mJ;
652
- // /***/sotCOUNTER(7,8); // P
653
- // }
654
- // }
655
- /* NON OPTIMAL FORM: to be replaced after debug. */
656
- // Proj-=Jp*Jt;
657
-
658
630
/* --- OLIVIER START --- */
659
631
sotDEBUG (2 ) << " Proj non optimal (rankJ= " <<rankJ
660
632
<< " , iterTask =" << iterTask
@@ -664,36 +636,7 @@ computeControlLaw( dynamicgraph::Vector& control,const int& iterTime )
664
636
sotDEBUG (2 ) << " JpxJt = " << Jp*Jt;
665
637
sotDEBUG (25 ) << " Proj-Jp*Jt" <<iterTask<<" = " << (Proj-Jp*Jt) <<endl;
666
638
667
- /* NON OPTIMAL FORM: to be replaced after debug. */
668
- if (1 )
669
- {
670
- double *p,*v1,*v2,*vtmp1,*vtmp2;
671
- p = MRAWDATA (Proj);
672
- v1 = MRAWDATA (V);
673
- v2 = MRAWDATA (V);
674
- vtmp1 = MRAWDATA (V);
675
- /* **/ sotCOUNTER (6 ,7 ); // Ppre
676
-
677
- for ( int i=0 ;i<mJ ;++i )
678
- {
679
- vtmp2 = MRAWDATA (V);
680
- for ( int j=0 ;j<mJ ;++j )
681
- {
682
- v1 = vtmp1; v2 =vtmp2;
683
- for (unsigned int k=0 ;k<rankJ;++k )
684
- // for( unsigned int k=0;k<mJ;++k )
685
- {
686
- (*p) -=( *v1) * (*v2);
687
- v2+=mJ ;v1+=mJ ;
688
- }
689
- p++; vtmp2 ++;
690
- }
691
- vtmp1++;
692
- }
693
- /* **/ sotCOUNTER (7 ,8 ); // P
694
- }
695
- else
696
- { Proj-=Jp*Jt;}
639
+ Proj.noalias () -= Jp * Jt;
697
640
698
641
/* --- OLIVIER END --- */
699
642
@@ -734,6 +677,7 @@ computeControlLaw( dynamicgraph::Vector& control,const int& iterTime )
734
677
dynamicgraph::Matrix &Jp = mem->Jp ;
735
678
dynamicgraph::Matrix &PJp = mem->PJp ;
736
679
dynamicgraph::Matrix &Jt = mem->Jt ;
680
+ MemoryTaskSOT::SVD_t& svd = mem->svd ;
737
681
738
682
mem->JK .resize ( nJ,mJ );
739
683
mem->Jt .resize ( nJ,mJ );
@@ -750,18 +694,17 @@ computeControlLaw( dynamicgraph::Vector& control,const int& iterTime )
750
694
sotDEBUG (35 ) << " Jgrad = " << JK <<endl;
751
695
752
696
// Use optimized-memory Jt to do the p-inverse.
753
- Jt=JK; Eigen::dampedInverse ( Jt, Jp,th );
754
- PJp = Proj*Jp;
697
+ Jt=JK;
698
+ svd.compute (Jt);
699
+ // TODO the two next lines could be replaced by
700
+ Eigen::dampedInverse ( svd, Jp,th );
701
+ PJp.noalias () = Proj*Jp;
755
702
756
703
/* --- COMPUTE ERR --- */
757
- dynamicgraph::Vector Herr ( err.size () );
758
- for ( int i=0 ;i<err.size (); ++i )
759
- {
760
- Herr (i) = err (i);
761
- }
704
+ const dynamicgraph::Vector& Herr ( err );
762
705
763
706
/* --- COMPUTE CONTROL --- */
764
- control += PJp*Herr;
707
+ control. noalias () += PJp*Herr;
765
708
766
709
/* --- TRACE --- */
767
710
sotDEBUG (45 ) << " Pgrad = " << (PJp*Herr) <<endl;
0 commit comments