Changes v2.2.0 to v2.3.0

Joel Andersson edited this page Apr 27, 2015 · 15 revisions

Changes v2.2.0 to v2.3.0:

  • The syntax: MX.repmat(A,n,m) is no longer available, only repmat(A,n,m). For disambiguation, use an explicit type cast: repmat(SX(4),n,m). Cf. #1300
  • sparse(A) has been renamed sparsify(A) (for for turning numerically zero entries into structurally zero entries).
  • The syntax for creating a sparse matrix has changed from MX.sparse(n,m) to MX(n,m) when there are no structural nonzeros and from MX.sparse(Sparsity,nz) to MX(Sparsity,nz) when sparsity pattern and nonzeros are given. The old syntax will be deprecated. Cf. #1300
  • dense(A) has been renamed densify(A) (for for turning structurally zero entries into numerically zero entries). The syntax for creating a dense sparsity patterns, Sparsity.dense(n,m), is unchanged. Cf. #1300
  • The syntax for obtaining the number of nonzeros of a matrix is now A.nnz() (in MATLAB nnz(A)). The old syntax A.size() will be deprecated. Cf. #1300
  • The function simplify(A) is now an immutable (const) function. The old implementation corresponds to A = simplify(A). Cf. #1300
  • The prefix SP_ has been added to the SparsityType enum, i.e. SP_SPARSE, SP_SPARSESYM, SP_DENSE, SP_DENSESYM and SP_DENSETRANS instead of SPARSE, SPARSESYM, DENSE, DENSESYM, DENSETRANS. Cf. #1324.
  • The way CasADi stores sparsity patterns has changed. It is still column compressed format, but stored in a different way. This means that the functions Sparsity::colind() and Sparsity::row() now returns const int* instead of const std::vector<int>& in C++. There is no change of syntax in Python. Cf. #1280. With the new representation, modifying a sparsity pattern (e.g. appending entries) is potentially less efficient. Where possible, vertical or horizontal concatenation (horzcat, vertcat) are always preferable to repeatedly appending entries.
  • The way derivatives and Jacobians are calculated by CasADi has changed. Internally, directional derivatives are calculated by generating functions that take the original function inputs and outputs and calculates directional derivatives. This is different from before, when the generated functions calculated original (non-differentiated) outputs together with directional derivatives. Also, forward and reverse mode derivatives are now treated separately. The old syntax is still valid, but using the new syntax (Function::callForward and Function::callReverse instead of Function::callDerivative) is recommended. Directional derivatives are, when it is deemed to be cheaper, automatically replaced by the generation of the Jacobian (of all outputs with respect to all inputs) and a matrix multiplication. To force using forward and/or reverse modes, use the option ad_weight instead of ad_mode, which has been deprecated. Cf. #1336
  • The behavior of Matrix::set and Matrix::get has changed. Now, Matrix::set(value) and Matrix::get(value) always means expect an array with the number of (dense) entries in the (optionally transposed) matrix. To provide only nonzeros, use Matrix::setNZ(value) and Matrix::getNZ(value) instead. Cf. #1322, #1360
  • The functions returning Matrix elements of Matrix have been removed from the public API (available via e.g. Python). This includes Matrix::elem, Matrix::at (use syntax A[i,j],[k] instead) and Matrix::data() (returning a reference to the structure storing nonzeros of the matrix). To get all nonzeros of a DMatrix, use DMatrix::nonzeros() instead. Instead of DMatrix::at, use DMatrix::getValue(k). Cf. #1322