-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d789d7e
commit 18fcdb3
Showing
55 changed files
with
3,248 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"Css classes in Calcpad | ||
'<p class="ref">[ref (float right)]</p> | ||
'<p>Design checks: <span class="ok">ok</span> / <span class="err">fail</span>. | ||
'Image (side) | ||
'<img class="side" style="height:114pt; width:127pt;" src="https://calcpad.eu/media/mechanics/beams/cantilever-beam-concentrated-force.png" alt="cantilever-beam-concentrated-force.png"> | ||
'<div class="fold"> | ||
'<h4>Fold heading</h4> | ||
'Folded content line 1 | ||
'Folded content line 2 | ||
'Folded content line 3... | ||
'</div> | ||
'Bordered table | ||
'<table class="bordered"> | ||
'<thead> | ||
'<tr><th>col 1</th><th>col 2</th></tr> | ||
'</thead> | ||
'<tbody> | ||
'<tr><td>'11'</td><td>'12'</td></tr> | ||
'<tr><td>'21'</td><td>'22'</td></tr> | ||
'</tbody> | ||
'</table> | ||
'Data table (first col aligned left, others - right) | ||
'<table class="data"> | ||
'<tbody> | ||
'<tr><td>Height -</td><td>111.0m</td></tr> | ||
'<tr><td>Thickness -</td><td>2cm</td></tr> | ||
'</tbody> | ||
'</table> |
14 changes: 14 additions & 0 deletions
14
Calcpad.Cli/Examples/Demos/Custom units/Currency units.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"Currency units | ||
'Definition | ||
.EUR = 1 | ||
.USD = 0.92EUR | ||
.BGN = 0.511291881196218EUR | ||
'Conversion | ||
10BGN|USD | ||
20EUR|BGN | ||
30EUR|USD | ||
'Usage | ||
'Unit price - 'p = 15USD/m | ||
'Order length -'L = 100m | ||
'Total price in USD -'P = p*L|USD | ||
'Total price in EUR -'P|EUR |
17 changes: 17 additions & 0 deletions
17
Calcpad.Cli/Examples/Demos/Custom units/Information units.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"Information units | ||
'Definition | ||
.bit = 1 | ||
.byte = 8bit | ||
.KB = 1000byte','.KiB = 1024byte | ||
.MB = 1000KB','.MiB = 1024KiB | ||
.TB = 1000MB','.TiB = 1024MiB | ||
.PB = 1000TB','.PiB = 1024TiB | ||
.EB = 1000PB','.EiB = 1024PiB | ||
.ZB = 1000EB','.ZiB = 1024EiB | ||
.YB = 1000ZB','.YiB = 1024ZiB | ||
'Conversion | ||
MiB|byte | ||
TiB|byte | ||
'Usage | ||
v = 10000000byte/s | ||
v|TiB/h |
52 changes: 52 additions & 0 deletions
52
Calcpad.Cli/Examples/Mathematics/Matrices/Matrix creational functions.cpd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'<style>em {font-family:"Times New Roman";}</style> | ||
"Matrix creational functions | ||
'<p><b>Matrix</b>(<em>m</em>; <em>n</em>)</p><hr/> | ||
matrix(3; 4)'- creates a 3x4 full (rectangular) matrix | ||
|
||
'<p><b>Identity</b>(<em>n</em>)</p><hr/> | ||
identity(3)'- creates a 3x3 identity matrix (diagonal filled with ones) | ||
|
||
'<p><b>Diagonal</b>(<em>n</em>, <em>value</em>)</p><hr/> | ||
diagonal(3; 2)'- creates a 3x3 diagonal matrix filled with 2 | ||
|
||
'<p><b>Column</b>(<em>m</em>, <em>value</em>)</p><hr/> | ||
column(3; 2)'- creates a 3x1 column matrix filled with 2 | ||
|
||
'<p><b>Utriang</b>(<em>n</em>, <em>value</em>)</p><hr/> | ||
U = utriang(3)'- creates a 3x3 upper triangular matrix | ||
mfill(U; 1)'- fills the matrix with value of 1 | ||
|
||
'<p><b>Ltriang</b>(<em>n</em>, <em>value</em>)</p><hr/> | ||
L = ltriang(3)'- creates a 3x3 lower triangular matrix | ||
mfill(L; 1)'- fills the matrix with value of 1 | ||
|
||
'<p><b>Symmetric</b>(<em>n</em>)</p><hr/> | ||
A = symmetric(4)'- creates a 4x4 empty symmetrix matrix | ||
A.(1; 1) = 5', 'A.(1; 2) = 4'- assign some values | ||
A.(2; 2) = 3', 'A.(2; 3) = 2 | ||
A.(4; 2) = 1', 'A.(4; 4) = 1 | ||
A'- symmetric values has also changed to preserve symmetry | ||
|
||
'<p><b>Vec2diag</b>(<em>vector</em>)</p><hr/> | ||
vec2diag([1; 2; 3])'- creates a 3x3 diagonal matrix from a vector | ||
|
||
'<p><b>Vec2col</b>(<em>vector</em>)</p><hr/> | ||
vec2col([1; 2; 3])'- creates a 3x3 column matrix from a vector | ||
|
||
'<p><b>Join_Cols</b>(<em>list of vectors</em>)</p><hr/> | ||
join_cols([1]; [4; 5; 6]; [7; 8]; [10; 11; 12])'- creates a general rectangular matrix by joining the input vectors into columns | ||
|
||
'<p><b>Join_Rows</b>(<em>list of vectors</em>)</p><hr/> | ||
join_rows([1; 2; 3; 4]; [6; 7; 8; 9; 10])'- creates a general rectangular matrix by joining the input vectors into rows | ||
|
||
'<p><b>Augment</b>(<em>list of matrices</em>)</p><hr/> | ||
A = [1; 2|3; 4] | ||
B = [1; 2; 3|4; 5; 6|7; 8; 9] | ||
c = [10; 11; 12; 13] | ||
D = augment(A; B; c)'- creates a general rectangular matrix by joining the input matrices side to side | ||
|
||
'<p><b>Stack</b>(<em>list of matrices</em>)</p><hr/> | ||
A = [1; 2|3; 4] | ||
B = [1; 2; 3|4; 5; 6|7; 8; 9] | ||
c = [10; 11] | ||
D = stack(A; B; c)'- creates a general rectangular matrix by joining the input matrices one below the other |
61 changes: 61 additions & 0 deletions
61
Calcpad.Cli/Examples/Mathematics/Matrices/Matrix data functions.cpd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
'<style>em {font-family:"Times New Roman";}</style> | ||
"Matrix data functions | ||
'<p><b>Sort_Cols</b>(<em>matrix</em>; <em>row index</em>) and <b>Rsort_Cols</b>(<em>matrix</em>; <em>row index</em>)</p><hr/> | ||
A = [5; 2; 3|4; 9; 1|6; 8; 7] | ||
B = sort_cols(A; 2)'- the matrix sorted by row 2 in ascending order | ||
C = rsort_cols(A; 2)'- the matrix sorted by row 2 in descending order | ||
A' - the original matrix remains unchanged | ||
|
||
'<p><b>Sort_Rows</b>(<em>matrix</em>; <em>column index</em>) and <b>Rsort_Rows</b>(<em>matrix</em>; <em>column index</em>)</p><hr/> | ||
A = [5; 2; 3|4; 9; 1|6; 8; 7] | ||
B = sort_rows(A; 2)'- the matrix sorted by column 2 in ascending order | ||
C = rsort_rows(A; 2)'- the matrix sorted by column 2 in descending order | ||
A' - the original matrix remains unchanged | ||
|
||
'<p><b>Order_Cols</b>(<em>matrix</em>; <em>row index</em>) and <b>Revorder_Cols</b>(<em>matrix</em>; <em>row index</em>)</p><hr/> | ||
A = [5; 2; 3|4; 9; 1|6; 8; 7] | ||
b = order_cols(A; 2)'- the indexes of matrix columns ordered by the values in row 2 in ascending order | ||
B = extract_cols(A; b)'- the matrix sorted by row 2 in ascending order | ||
c = revorder_cols(A; 2)'- the indexes of matrix columns ordered by the values in row 2 in descending order | ||
C = extract_cols(A; c)'- the matrix sorted by row 2 in descending order | ||
|
||
'<p><b>Order_Rows</b>(<em>matrix</em>; <em>column index</em>) and <b>Revorder_Rows</b>(<em>matrix</em>; <em>column index</em>)</p><hr/> | ||
A = [5; 2; 3|4; 9; 1|6; 8; 7] | ||
b = order_rows(A; 2)'- the indexes of matrix rows ordered by the values in column 2 in ascending order | ||
B = extract_rows(A; b) | ||
c = revorder_rows(A; 2)'- the matrix sorted by row 2 in descending order | ||
C = extract_rows(A; c)'- the indexes of matrix rows ordered by the values in column 2 in descending order | ||
|
||
'<p><b>Mcount</b>(<em>matrix</em>; <em>value</em>)</p><hr/> | ||
A = [1; 0; 1|2; 1; 2|1; 3; 1] | ||
n = mcount(A; 1)'- the number of occurances of value 1 in matrix A | ||
|
||
'<p><b>Msearch</b>(<em>matrix</em>; <em>value</em>; <em>starting row index</em>; <em>starting column index</em>)</p><hr/> | ||
A = [1; 2; 3|1; 5; 6|1; 8; 9] | ||
b = msearch(A; 1; 1; 1)' - the row and column indexes of the first occurance of value 1 in A, starting from (1,1) | ||
c = msearch(A; 1; 2; 2)' - the same are previous, but starting from (2,2) | ||
d = msearch(A; 4; 1; 1)' - if the value is not found [0 0] is returned | ||
|
||
'<p><b>Mfind</b>(<em>matrix</em>; <em>value</em>)</p><hr/> | ||
A = [1; 2; 3|4; 1; 6|1; 8; 9] | ||
B = mfind(A; 1)' - the row and column indexes of all elements in A, that are equal to 1 | ||
C = mfind_ne(A; 1)' - the row and column indexes of all elements in A, that are not equal to 1 | ||
D = mfind_lt(A; 5)' - the row and column indexes of all elements in A, that are less than 5 | ||
E = mfind(A; 5)'- if the value is not found | ||
|
||
'<p><b>Hlookup</b>(<em>matrix</em>; <em>value</em>; <em>reference row</em>; <em>return row</em>)</p><hr/> | ||
A = [0; 1; 0; 1|1; 2; 3; 4; 5|6; 7; 8; 9; 10] | ||
b = hlookup(A; 0; 1; 3)'- the values in row 3, where row 1 contains zeros | ||
c = hlookup_ne(A; 0; 1; 3)'- the values in row 3, where row 1 does not contain zeros | ||
d = hlookup_lt(A; 9; 3; 2)'- the values in row 2, where the respective values in row 3 are < 9 | ||
e = hlookup_ge(A; 8; 3; 2)'- the values in row 2, where the respective values in row 3 are ≥ 8 | ||
f = hlookup(A; 0; 1; 3)'- the values in row 3, where row 1 contains zeros | ||
g = hlookup(A; 2; 1; 3)'- since 2 is not found in row 1, an empty vector is returned | ||
|
||
'<p><b>Vlookup</b>(<em>matrix</em>; <em>value</em>; <em>reference column</em>; <em>return column</em>)</p><hr/> | ||
A = [1; 2|3; 4; 1|5; 6|7; 8; 1|9; 10] | ||
b = vlookup(A; 0; 3; 1)'- the values in column 1, where column 3 contains zeros | ||
c = vlookup_ne(A; 0; 3; 2)'- the values in column 2, where column 3 does not contain zeros | ||
d = vlookup_le(A; 5; 1; 2)'- the values in column 2, where the respective values in column 1 are ≤ 5 | ||
e = vlookup_gt(A; 3; 1; 2)'- the values in column 2, where the respective values in column 1 are > 3 | ||
f = vlookup(A; 2; 3; 1)'- since 2 is not found in column 3, an empty vector is returned |
31 changes: 31 additions & 0 deletions
31
Calcpad.Cli/Examples/Mathematics/Matrices/Matrix initialization and indexing.cpd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"Matrix initialization | ||
'Direct: | ||
A = [1|2; 3|4; 5; 6|7; 8] | ||
'Direct with vectors: | ||
a = [1; 2; 4] | ||
A = [a|2*a + 1|3*a + 2] | ||
'From a custom function (with vector arguments): | ||
A(x) = transp([x^0|x|x^2|x^3|x^4]) | ||
x = [1; 2; 3; 4] | ||
A = A(x) | ||
|
||
"Indexing | ||
A.(3; 2)'- simple dot operator (constant index) | ||
i = 2', 'j = 3 | ||
A.(2*i - 1; j + 1)'- expressions with variables | ||
A.(i; j) = 0' - assign a new value to an element:'A | ||
'Initalize values in a block loop | ||
x = [1; 2; 3; 4] | ||
A = matrix(len(x); 7) | ||
#hide | ||
#for i = 1 : n_rows(A) | ||
#for j = 1 : n_cols(A) | ||
A.(i; j) = x.i^(j - 1) | ||
#loop | ||
#loop | ||
#show | ||
A | ||
'Inline loop | ||
B = matrix(len(x); 7) | ||
$Repeat{$Repeat{B.(i; j) = x.i^(j - 1) @ j = 1 : n_cols(B)} @ i = 1 : n_rows(B)} | ||
B |
Oops, something went wrong.