mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 11:49:02 +08:00
extend matlab conversion table
This commit is contained in:
parent
6639b7d6e8
commit
f9d71a1729
@ -43,6 +43,8 @@ MatrixXd::Random(rows,cols) // rand(rows,cols)*2-1 // MatrixXd::R
|
|||||||
C.setRandom(rows,cols) // C = rand(rows,cols)*2-1
|
C.setRandom(rows,cols) // C = rand(rows,cols)*2-1
|
||||||
VectorXd::LinSpaced(size,low,high) // linspace(low,high,size)'
|
VectorXd::LinSpaced(size,low,high) // linspace(low,high,size)'
|
||||||
v.setLinSpaced(size,low,high) // v = linspace(low,high,size)'
|
v.setLinSpaced(size,low,high) // v = linspace(low,high,size)'
|
||||||
|
VectorXi::LinSpaced(((hi-low)/step)+1, // low:step:hi
|
||||||
|
low,low+step*(size-1))
|
||||||
|
|
||||||
|
|
||||||
// Matrix slicing and blocks. All expressions listed here are read/write.
|
// Matrix slicing and blocks. All expressions listed here are read/write.
|
||||||
@ -85,13 +87,15 @@ P.bottomRightCorner<rows,cols>() // P(end-rows+1:end, end-cols+1:end)
|
|||||||
R.row(i) = P.col(j); // R(i, :) = P(:, i)
|
R.row(i) = P.col(j); // R(i, :) = P(:, i)
|
||||||
R.col(j1).swap(mat1.col(j2)); // R(:, [j1 j2]) = R(:, [j2, j1])
|
R.col(j1).swap(mat1.col(j2)); // R(:, [j1 j2]) = R(:, [j2, j1])
|
||||||
|
|
||||||
// Views, transpose, etc; all read-write except for .adjoint().
|
// Views, transpose, etc;
|
||||||
// Eigen // Matlab
|
// Eigen // Matlab
|
||||||
R.adjoint() // R'
|
R.adjoint() // R'
|
||||||
R.transpose() // R.' or conj(R')
|
R.transpose() // R.' or conj(R') // Read-write
|
||||||
R.diagonal() // diag(R)
|
R.diagonal() // diag(R) // Read-write
|
||||||
x.asDiagonal() // diag(x)
|
x.asDiagonal() // diag(x)
|
||||||
R.transpose().colwise().reverse(); // rot90(R)
|
R.transpose().colwise().reverse() // rot90(R) // Read-write
|
||||||
|
R.replicate(i,j) // repmat(P,i,j)
|
||||||
|
|
||||||
|
|
||||||
// All the same as Matlab, but matlab doesn't have *= style operators.
|
// All the same as Matlab, but matlab doesn't have *= style operators.
|
||||||
// Matrix-vector. Matrix-matrix. Matrix-scalar.
|
// Matrix-vector. Matrix-matrix. Matrix-scalar.
|
||||||
@ -134,6 +138,8 @@ R.array().abs() // abs(P)
|
|||||||
R.cwiseAbs2() // abs(P.^2)
|
R.cwiseAbs2() // abs(P.^2)
|
||||||
R.array().abs2() // abs(P.^2)
|
R.array().abs2() // abs(P.^2)
|
||||||
(R.array() < s).select(P,Q ); // (R < s ? P : Q)
|
(R.array() < s).select(P,Q ); // (R < s ? P : Q)
|
||||||
|
R = (Q.array()==0).select(P,A) // R(Q==0) = P(Q==0)
|
||||||
|
|
||||||
|
|
||||||
// Reductions.
|
// Reductions.
|
||||||
int r, c;
|
int r, c;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user