Skip to content

Commit

Permalink
Version 2.0.0
Browse files Browse the repository at this point in the history
Version 2.0.0
  • Loading branch information
lmendo committed Dec 17, 2015
1 parent 3bd8bd8 commit ad77b35
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 11 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk

# Added manually
MATLp.txt
MATLc.m
funDef_outtakes.txt
defin
inout
defout
Binary file modified MATL_spec.pdf
Binary file not shown.
Binary file modified funDef.mat
Binary file not shown.
14 changes: 8 additions & 6 deletions funDef.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
% - description (for LaTeX)
%
% src minIn maxIn defIn minOut maxOut defOut consumeInputs wrap body Comment (for matl) description (for LaTex)
! 1 1 1 1 1 1 true true out{1} = in{1}.'; transpose \matlab+.'+ (\matlab+transpose+)
! 1 2 1 1 1 1 true true if numel(in)==1, out{1} = in{1}.'; transpose / permute array dimensions With $1$ input: \matlab+.'+ (\matlab+transpose+). With $2$ inputs: \matlab+permute+
else out{1} = permute(in{:}); end
X! 1 2 1 1 1 1 true true out{1} = rot90(in{:}); rotate array 90 degrees \matlab+rot90+
Y! 1 1 1 0 2 2 true true [out{:}] = system(in{:}); execute system command \matlab+system+
Z! 1 1 1 1 1 1 true true out{1} = full(in{1}); convert sparse matrix to full matrix \matlab+full+
Expand Down Expand Up @@ -375,7 +376,7 @@ XS 1 2 1 1 2 1 true true [out{:}] = sortrows(in{:}); sort rows \matlab+sortrows+
YS 2 3 2 1 1 1 true true out{1} = circshift(in{:}); circular shift \matlab+circshift+
ZS 1 2 1 1 1 1 true true out{1} = squareform(in{:}); reformat distance matrix between upper triangular and square form \matlab+squareform+
T
XT
XT 0 0 0 1 1 1 true true out{1} = pi; pi \matlab+pi+
YT 1 2 2 1 1 1 true true out{1} = toeplitz(in{:}); Toeplitz matrix \matlab+toeplitz+
ZT
U
Expand Down Expand Up @@ -446,9 +447,10 @@ d 1 3 1 1 1 1 true true out{1} = diff(in{:}); difference \matlab+diff+
Xd 1 2 1 1 1 1 true true out{1} = diag(in{:}); diagonal matrices and diagonals of a matrix \matlab+diag+
Yd 1 inf 2 1 1 1 true true out{1} = blkdiag(in{:}); block diagonal concatenation \matlab+blkdiag+
Zd 2 2 2 1 3 1 true true [out{:}] = gcd(in{:}); greatest common divisor \matlab+gcd+
e 2 inf 3 1 1 1 true true out{1} = reshape(in{:}); reshape array \matlab+reshape+
Xe 2 2 2 1 1 1 true true out{1} = permute(in{:}); permute array dimensions \matlab+permute+
Ye 1 1 1 1 1 1 true true out{1} = squeeze(in{:}); remove singleton dimensions \matlab+squeeze+
e 1 inf 3 1 1 1 true true if numel(in)>1, out{1} = reshape(in{:}); reshape array / remove singleton dimensions With more than $1$ input: \matlab+reshape+. With $1$ input: \matlab+squeeze+.
else out{1} = squeeze(in{:}); end
Xe
Ye
Ze 1 1 1 1 1 1 true true out{1} = exp(in{:}); exponential \matlab+exp+
f 1 3 1 1 3 1 true true [out{:}] = find(in{:}); find \matlab+find+
Xf 2 4 2 1 1 1 true true out{1} = strfind(in{:}); find one string within another \matlab+strfind+
Expand Down Expand Up @@ -493,7 +495,7 @@ Xn 2 2 2 1 1 1 true true out{1} = nchoosek(in{:}); binomial coefficient or all c
Yn 1 5 2 1 1 1 true true out{1} = interp1(in{:}); interpolation (table lookup) \matlab+interp1+. \matlab+'pp'+ option not supported
Zn
o 1 1 1 1 1 1 true true out{1} = double(in{1}); convert to double precision \matlab+double+
Xo 0 0 0 1 1 1 true true out{1} = pi; pi \matlab+pi+
Xo 1 1 1 1 1 1 true true out{1} = uint64(in{1}); convert to unsigned 64-bit integer \matlab+uint64+
Yo 1 3 1 1 1 1 true true out{1} = round(in{:}); round towards nearest decimal or integer \matlab+round+
Zo 1 1 1 1 1 1 true true out{1} = fix(in{:}); round to nearest integer towards zero \matlab+fix+
p 1 3 1 1 1 1 true true out{1} = prod(in{:}); product of elements \matlab+prod+
Expand Down
4 changes: 2 additions & 2 deletions genFunDef.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function F = genFunDef(masterFileName, fileName)
%
% Generates function definition struct array "F" from tab-separated text
% file, and saves it in file "funDef.mat"
% file, and saves it in file.
%
% The tab-separated file has one or more lines for each function.
% The first line for each function contains its source code in the first
Expand All @@ -14,7 +14,7 @@
% filled. In that case, this function collects all lines in a cell array of
% strings.
%
% Luis Mendo.
% Luis Mendo

fieldNames = {'source' 'minIn' 'maxIn' 'defIn' 'minOut' 'maxOut' 'defOut' 'consumeInputs' 'wrap' 'body' 'comment' 'description'};
fid = fopen(masterFileName, 'r');
Expand Down
5 changes: 5 additions & 0 deletions genPreLit.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
function L = genPreLit(masterFileName, fileName)
%
% Generates struct array "L" for predefined literals from tab-separated text
% file, and saves it in file.
%
% Luis Mendo

fid = fopen(masterFileName, 'r');
p = reshape(fread(fid,inf,'*char'),1,[]);
Expand Down
Binary file modified help.mat
Binary file not shown.
6 changes: 3 additions & 3 deletions matl_parse.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
(s(pos)=='.' && pos<L && any(s(pos+1)=='0123456789'))
% It may be a number literal such as +3.4e-5j, or a two-number colon array such as
% -2.3:.4e2, or three-number colon array such as 10:-2.5e-1:.5e-5
[ini, fin] = regexp(s(pos:end), '([+-]?(\d+\.?\d*|\d*\.?\d+)(e[+-]?\d+)?[ij]?\s*:\s*){0,2}[+-]?(\d+\.?\d*|\d*\.?\d+)(e[+-]?\d+)?[ij]?', 'once');
[ini, fin] = regexp(s(pos:end), '([+-]?(\d+\.?\d*|\d*\.?\d+)(e[+-]?\d+)?j?\s*:\s*){0,2}[+-]?(\d+\.?\d*|\d*\.?\d+)(e[+-]?\d+)?j?', 'once');
if ~isempty(ini) && ini==1
if any(s(pos:pos-1+fin)==':') % It's a colon array literal
S(n).type = 'literal.colonArray.numeric';
Expand Down Expand Up @@ -95,10 +95,10 @@
n = n + 1;
elseif s(pos)=='''' % It's a string. Consume until next single ' (duplicated ' symbols don't close the string).
% Or it may be a char colon array. It has first and last operands char.
[ini, fin] = regexp(s(pos:end), '^''([^'']|'''')*?''(?!'')((:(''([^'']|'''')*?''(?!'')|[+-]?(\d+\.?\d*|\d*\.?\d+)(e[+-]?\d+)?[ij]?))?:''([^'']|'''')*?''(?!''))?', 'once');
[ini, fin] = regexp(s(pos:end), '^''([^'']|'''')*?''(?!'')((:(''([^'']|'''')*?''(?!'')|[+-]?(\d+\.?\d*|\d*\.?\d+)(e[+-]?\d+)?j?))?:''([^'']|'''')*?''(?!''))?', 'once');
% The structure of this regular expresion is: 'c((:(c|n))?:c)?', where
% `c` (`^''([^'']|'''')*?''(?!'')`) indicates string and
% `n` (`[+-]?(\d+\.?\d*|\d*\.?\d+)(e[+-]?\d+)?[ij]?`) indicates number
% `n` (`[+-]?(\d+\.?\d*|\d*\.?\d+)(e[+-]?\d+)?j?`) indicates number
assert(~isempty(ini), 'MATL:parser', 'MATL error while parsing: string literal not closed')
assert(ini==1, 'MATL:parser:internal', 'MATL internal error while parsing string/colon array literal')
if any(s(pos:pos-1+fin)==':') % It's a (char) colon array literal
Expand Down
Binary file modified preLit.mat
Binary file not shown.
1 change: 1 addition & 0 deletions preLit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ Y2
2 'a':'z'
3 ['A':'Z' 'a':'z']
4 '0':'9'
5 ['0':'9' 'A':'F']
11 'aeiou'
12 'AEIOU'
13 'aeiouAEIOU'

0 comments on commit ad77b35

Please sign in to comment.