You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Milestone: 1.0 Status: closed Owner: nobody Labels: new feature (4)
Updated: 2012-12-06 Created: 2012-11-22 Creator: Joachim Ferreau Private: No
Why not support the diag command? Here the code for
Vector v = diag(Matrix M) ,
Matrix M = diag(Vector v) ,
ExportVariable Q = diag( name,dim ) ,
the latter setting up a diagonal, user-defined variable (i.e. off-diagonal elements are ignored when exporting code):
I) include/acado/symbolic_expression/acado_syntax.hpp:
include <acado/code_generation/export_variable.hpp>
REFER_NAMESPACE_ACADO Matrix diag ( const REFER_NAMESPACE_ACADO Vector& v );
REFER_NAMESPACE_ACADO Vector diag ( const REFER_NAMESPACE_ACADO Matrix& M );
REFER_NAMESPACE_ACADO ExportVariable diag( const REFER_NAMESPACE_ACADO String& _name, unsigned int _n );
II) src/symbolic_expression/acado_syntax.cpp:
Matrix diag( const Vector& v )
{
int n = v.getDim();
Matrix t = zeros( n,n );
for( int i=0; i<n; ++i )
t(i,i) = v(i);
return t;
Milestone: 1.0 Status: closed Owner: nobody Labels: new feature (4)
Updated: 2012-12-06 Created: 2012-11-22 Creator: Joachim Ferreau Private: No
Why not support the diag command? Here the code for
Vector v = diag(Matrix M) ,
Matrix M = diag(Vector v) ,
ExportVariable Q = diag( name,dim ) ,
the latter setting up a diagonal, user-defined variable (i.e. off-diagonal elements are ignored when exporting code):
I) include/acado/symbolic_expression/acado_syntax.hpp:
include <acado/code_generation/export_variable.hpp>
REFER_NAMESPACE_ACADO Matrix diag ( const REFER_NAMESPACE_ACADO Vector& v );
REFER_NAMESPACE_ACADO Vector diag ( const REFER_NAMESPACE_ACADO Matrix& M );
REFER_NAMESPACE_ACADO ExportVariable diag( const REFER_NAMESPACE_ACADO String& _name, unsigned int _n );
II) src/symbolic_expression/acado_syntax.cpp:
Matrix diag( const Vector& v )
{
int n = v.getDim();
}
Vector diag( const Matrix& M )
{
ASSERT( M.isSquare() == BT_TRUE );
}
ExportVariable diag( const String& _name,
unsigned int _n )
{
ExportVariable t( _name, _n,_n );
t = eye( _n );
t.resetDiagonal( );
return t;
}
Discussion
Joachim Ferreau
2012-12-06
status: open --> closed
The text was updated successfully, but these errors were encountered: