Mathematical Operations
What are the commands for the most important mathematical operations in Julia and R? The following table translates the most common Julia commands into R language.
Julia | R | |
---|---|---|
Dot product | ||
dot(a,b) |
a%*%b |
|
Matrix multiplication | ||
A * B |
A%*%B |
|
Element-wise multiplication | ||
A .* B |
A * B |
|
Matrix to a power |
||
A^2 |
require(exem) A%^%2 |
|
Matrix to a power, elementwise |
||
A.^2 |
A^2 |
|
Inverse |
||
inv(A) |
solve(A) |
|
Determinant |
||
det(A) |
det(A) |
|
Eigenvalues and eigenvectors |
||
eig(A) |
eigen(A) |
|
Euclidean norm |
||
norm(A) |
norm(A, type="2") |
|
Solve least squares problem Ax = b |
||
A\b |
solve(a,b) |
Complete Julia-R Cheatsheet
1) Creating Vectors
2) Creating Matrices
3) Creating Random Numbers
4) Manipulating Vectors and Matrices
5) Accessing Vector/Matrix Elements