this is for holding javascript data
Jiahao Chen Add Matlab cases
over 8 years ago
Commit id: c1b6b7a7b4f98759203a0611067f534c41c7c250
deletions | additions
diff --git a/code/programs/Makefile b/code/programs/Makefile
index e46e96f..841dc89 100644
--- a/code/programs/Makefile
+++ b/code/programs/Makefile
...
DIR_EIGEN=/usr DIR_EIGEN=/usr/local/Cellar/eigen/3.2.6/
CXX=c++
CXXOPTS=-std=c++11 -Wall -Wno-unused-variable -Wno-deprecated-declarations
MATLAB=octave
TORCH=$(HOME)/torch/install/bin/th
all: bin/eigen3
matlab r julia torch
bin/eigen3
matlab: matlab.m
$(MATLAB) matlab.m
r: R.R
R -f R.R > /dev/null
diff --git a/code/programs/matlab.m b/code/programs/matlab.m
new file mode 100644
index 0000000..ccf3249
--- /dev/null
+++ b/code/programs/matlab.m
...
m1 = 6;
n1 = 5;
m2 = n1;
n2 = 4;
A = ones(m1, n1);
B = ones(m2, n2);
x = ones(1, m1);
y = ones(n1, 1);
alpha = ones(1);
assert(all(size(A*B) == [m1, n2]));
assert(all(size(alpha*A) == [m1, n1]));
assert(all(size(A*alpha) == [m1, n1]));
diff --git a/section_reallanguages.tex b/section_reallanguages.tex
index a03e4c4..4a05e24 100644
--- a/section_reallanguages.tex
+++ b/section_reallanguages.tex
...
R also has matrices, but no true scalars.
Its matrix multiplication operator is \verb|%*%| and its transposition operator
is \verb|t()|.
R's
transposition operator semantics promotes
vectors $n$-vectors automatically to
column matrices
before whenever linear algebraic
operations like \verb|t()| or \verb\%*%| are encountered.
By default, $n$-vectors behave as if they were $1\times n$ row matrices, except in
transposition,
producing which produces a row
matrix, and in matrix--vector products, which
produce a column matrix.
Like Python, \verb|%*%| is also defined on two vectors to be the dot product.
However, unlike Python, \verb|%*%|
also permits has a
vector--matrix product, special case where
it implicitly
transposes if the
vector into second operand
is a length 1 vector, the result is a
row matrix before doing an ordinary matrix
multiplication. $1\times n$ matrix.
Extraneous singleton dimensions can be removed with
\verb|drop()|. \verb|drop()|, which converts
either $n\times1$ or $1\times n$ matrices into $n$-vectors.
R's semantics
of vectors and matrices are simple to reason about.
Perhaps the only behavior that some users may find surprising is imply that transposition is not idempotent on vectors.
Nevertheless, we've already seen precedent in the mathematical literature
that does...
\todo{cite}