@zushah/chalkboard 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -2
- package/LICENSE.md +1 -1
- package/README.md +52 -45
- package/dist/Chalkboard.d.ts +198 -7
- package/dist/Chalkboard.d.ts.map +1 -1
- package/dist/Chalkboard.js +3648 -388
- package/dist/Chalkboard.js.map +1 -1
- package/package.json +63 -57
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
# Chalkboard changelog
|
|
2
2
|
All notable changes of every update of the Chalkboard library are recorded in this file.
|
|
3
3
|
|
|
4
|
+
## [v2.3.0 Boole](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.3.0) - 04/14/2025
|
|
5
|
+
The thirteenth release of the Chalkboard library.
|
|
6
|
+
Commits: [`v2.2.0...v2.3.0`](https://www.github.com/Zushah/Chalkboard/compare/v2.2.0...v2.3.0)
|
|
7
|
+
- Added `I` which calculates the number i
|
|
8
|
+
- Added boolean algebra functionalities with the new `bool` category containing 23 commands, which are mentioned below
|
|
9
|
+
- Added `bool.AND`, `bool.OR`, `bool.XOR`, `bool.COND`, `bool.CONV`, `bool.BICOND`, `bool.NOT`, `bool.NAND`, `bool.NOR`, `bool.NCOND`, `bool.NCONV`, and `bool.NBICOND` which are boolean operations that act on two or more values
|
|
10
|
+
- Added `bool.parse` which evaluates or simplifies a boolean expression, `bool.minimize` which minimizes a boolean expression, and `bool.isEqual` which checks if two boolean expressions are logically equivalent
|
|
11
|
+
- Added `bool.truthTable` which calculates the truth table for one or more boolean operators
|
|
12
|
+
- Added `bool.Karnaugh` which defines the Karnaugh map (or K-map) for a boolean expression and `bool.mapping` which defines a function that maps inputs to outputs based on truth tables
|
|
13
|
+
- Added `bool.primeImplicants` which calculates the prime implicants of a boolean expression using its Karnaugh map
|
|
14
|
+
- Added `bool.toCNF` which converts a boolean expression to conjunctive normal form and `bool.toDNF` which converts a boolean expression to disjunctive normal form
|
|
15
|
+
- Added `bool.modeConfig` which can change the mode of the `bool` commands to output either `1`/`0` (which is `"binary"` mode) or `true`/`false` (which is `"boolean"` mode)
|
|
16
|
+
- Added `numb.toBinary`, `numb.toHexadecimal`, and `numb.toOctal` which convert numbers from decimal representation to binary, hexadecimal, or octal representations
|
|
17
|
+
- Added `numb.toDecimal` which converts a number from another representation back to decimal representation
|
|
18
|
+
- Added `real.absolute`, `real.add`, `real.compose`, `real.div`, `real.mul`, `real.negate`, `real.pow` `real.reciprocate`, `real.scl`, `real.sub`, and `real.translate` which calculate the absolute value of a function, the addition of two functions, the composition of two functions, the division of two functions, the multiplication of two functions, the negation of a function, the exponentation of a function, the reciprocation of a function, the scalar multiplication of a function, the subtraction of two functions, and the translation of a function, respectively
|
|
19
|
+
- Added `real.polynomial` which defines a polynomial function based on inputted coefficients, and added `real.randomPolynomial` which defines a polynomial of a specified degree with random coefficients
|
|
20
|
+
- Changed `real.define` to be written more efficiently
|
|
21
|
+
- Changed `stat.random` to have its first parameter be the length of the array instead of the last
|
|
22
|
+
- Fixed `comp.pow`, `matr.norm`, `matr.normsq`, `plot.definition`, and `stat.regression` which were throwing type errors because of the updated `real.pow` function which can now handle not only numbers but also functions
|
|
23
|
+
- Fixed `comp.zero`, `quat.zero`, and `vect.zero` which were unnecessarily using erasing operations
|
|
24
|
+
|
|
25
|
+
## [v2.2.0 Galois](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.2.0) - 04/07/2025
|
|
26
|
+
The twelfth release of the Chalkboard library.
|
|
27
|
+
Commits: [`v2.1.0...v2.2.0`](https://www.github.com/Zushah/Chalkboard/compare/v2.1.0...v2.2.0)
|
|
28
|
+
- Added abstract algebra functionalities with the new `abal` category containing 76 commands, so only a few notable ones are mentioned below
|
|
29
|
+
- Added `abal.set` which defines a mathematical set, as well as `abal.Z` which defines the set of integers or the set of integers modulo n, `abal.Q` which defines the set of rational numbers, `abal.R` which defines the set of real numbers, and `abal.C` which defines the set of complex numbers or the set of nth roots of unity
|
|
30
|
+
- Added `abal.union`, `abal.intersection`, `abal.complement`, `abal.difference`, `abal.symmetricDifference`, `abal.Cartesian`, `abal.powerSet`, `abal.isSubset`, and `abal.isSuperset` which respectively calculate the union of two sets, the intersection of two sets, the complement of a set, the difference of two sets, the symmetric difference of two sets, the Cartesian product of two sets, the power set of a set, whether or not a set is a subset of another set, and whether or not a set is a superset of another set
|
|
31
|
+
- Added `abal.group`, `abal.ring`, and `abal.field` which define the algebraic structures known as groups, rings, and fields
|
|
32
|
+
- Added `abal.direct` which calculates the direct sum or direct product of two algebraic structures
|
|
33
|
+
- Added `abal.cosets` and `abal.quotient` which respectively calculate the cosets or quotient structure of two inputted algebraic structures
|
|
34
|
+
- Added `abal.homomorphism`, `abal.endomorphism`, `abal.isomorphism`, `abal.automorphism`, `abal.idmorphism`, and `abal.invmorphism` which define various types of morphisms between one or two algebraic structures
|
|
35
|
+
- Added `abal.compose` which calculates the composition morphism of two given morphisms
|
|
36
|
+
- Added `abal.image`, `abal.preimage`, and `abal.kernel` which respectively calculate the image, preimage, or kernel of a given morphism
|
|
37
|
+
- Added `abal.cardinality` which calculates the cardinality of a set or the set of a structure
|
|
38
|
+
- Added `abal.isEqual` which checks if two sets, structures, or morphisms are equal
|
|
39
|
+
- Added `abal.copy` which creates a copy of a set, structure, or morphism
|
|
40
|
+
- Added `abal.toArray`, `abal.toMatrix`, `abal.toObject`, `abal.toString`, `abal.toTensor`, and `abal.toVector` which convert sets or structures to arrays, matricies, objects, strings, tensors, or vectors, and `abal.print` prints a set or structure in the console
|
|
41
|
+
- Added `stat.Bayes` which calculates the posterior probability given prior probabilities
|
|
42
|
+
- Added `stat.expected` which calculates the expected value of an array given the probabilities of its elements
|
|
43
|
+
- Added `stat.normal` and `stat.inormal` which respectively calculate the values of the standard normal distribution and cumulative distribution function of the standard normal distribution
|
|
44
|
+
- Added `stat.resampling` which resamples an array either by the bootstrap or jackknife methods
|
|
45
|
+
- Added `stat.interpolate` which linearly or quadratically interpolates missing elements in an array
|
|
46
|
+
- Added `stat.absolute` which takes the absolute value of the elements of an array, `stat.negate` which negates the elements of an array, `stat.add` which adds the elements of two arrays, `stat.sub` which subtracts the elements of two arrays, `stat.dot` which calculates the dot product of two arrays, `stat.scl` which scales the elements of an array by a given number, `stat.sum` which calculates the sum of the elements of an array, `stat.mul` which calculates the product of the elements of an array, and `stat.reverse` which reverses the elements of an array
|
|
47
|
+
- Added `stat.cumsum`, `stat.cummul`, `stat.cummax`, and `stat.cummin` which respectively calculate the cumululative sum, product, maximum, and minimum of an array
|
|
48
|
+
- Added `stat.meanMoving` and `stat.meanWeighted` which respectively calculate the moving and weighted averages of an array
|
|
49
|
+
- Added `stat.covariance` which calculates the covariance of two arrays and `stat.correlationCoefficient` which calculates the correlation coefficient of two arrays
|
|
50
|
+
- Added `stat.interquartileRange` which calculates the interquartile range of an array
|
|
51
|
+
- Added `stat.zscored` which standardizes the elements of an array by their mean and standard deviation
|
|
52
|
+
- Added `stat.pad` which pads an array by a given element to a given length
|
|
53
|
+
- Added `stat.unique` which deduplicates an array of numbers, arrays, objects, etc.
|
|
54
|
+
- Added `matr.toSet`, `stat.toSet` and `tens.toSet` to convert matrices, arrays, and tensors to sets
|
|
55
|
+
- Added `numb.toFraction` to convert decimals to fractions and `numb.isRational` to check if a number is rational
|
|
56
|
+
- Changed `APPLY` to work for sets and algebraic structures introduced in the `abal` category
|
|
57
|
+
- Changed `stat.change` and `stat.chiSquared` to be written more succinctly
|
|
58
|
+
- Changed `stat.confidenceInterval` to use an adjustable confidence level
|
|
59
|
+
- Changed `stat.toMatrix` to be able to use only one parameter for the size of the matrix instead of requiring two
|
|
60
|
+
- Changed `matr.rotator` to be faster
|
|
61
|
+
- Changed `comp.toString` to output 1, i, -1, or -i when 1+0i, 0+1i, -1+0i, or 0-1i are inputted
|
|
62
|
+
- Fixed `comp.div` which was broken for who knows how long because it was using the wrong formula for some reason
|
|
63
|
+
- Fixed `matr.resize` which was always returning zero matrices
|
|
64
|
+
- Fixed `matr.zero` which was unnecessarily using erasing operations
|
|
65
|
+
- Fixed `tens.init` which had an expression assigned to itself
|
|
66
|
+
- Fixed `geom.rectangularprismA` thanks to @gyang0's contribution [here](https://github.com/Zushah/Chalkboard/pull/5)
|
|
67
|
+
|
|
4
68
|
## [v2.1.0 Seki](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.1.0) - 01/22/2024
|
|
5
69
|
The eleventh release of the Chalkboard library.
|
|
6
70
|
Commits: [`v2.0.0...v2.1.0`](https://www.github.com/Zushah/Chalkboard/compare/v2.0.0...v2.1.0)
|
|
@@ -42,7 +106,7 @@ Commits: [`v1.7.0...v2.0.0`](https://www.github.com/Zushah/Chalkboard/compare/v1
|
|
|
42
106
|
- Changed `real.function` to be renamed as `real.define`, `comp.function` to be renamed as `comp.define`, and `plot.function` to be renamed as `plot.definition`
|
|
43
107
|
- Changed `LOGO` to draw the logo as a circle instead of a square
|
|
44
108
|
- Changed `matr.mulvec` to be renamed as `matr.mulVector`
|
|
45
|
-
- Fixed `matr.mulVector
|
|
109
|
+
- Fixed `matr.mulVector` which didn't work when the rows of the matrix equaled the dimension of the vector
|
|
46
110
|
- Discontinued the Processsing.js edition of the library, meaning it will no longer be updated and it will only be available on the Khan Academy release (it will no longer be available on GitHub)
|
|
47
111
|
|
|
48
112
|
## [v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0) - 01/01/2024
|
|
@@ -206,4 +270,4 @@ Commits: [`v1.0.0...v1.1.0`](https://www.github.com/Zushah/Chalkboard/compare/v1
|
|
|
206
270
|
|
|
207
271
|
## [v1.0.0 Euclid](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) - 11/06/2023
|
|
208
272
|
The first release of the Chalkboard library.
|
|
209
|
-
Commits: [`v1.0.0...main`](https://www.github.com/Zushah/Chalkboard/compare/v1.0.0...main)
|
|
273
|
+
Commits: [`v1.0.0...main`](https://www.github.com/Zushah/Chalkboard/compare/v1.0.0...main)
|
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<p align="center"><a href="https://www.github.com/Zushah/Chalkboard"><img src="https://raw.githubusercontent.com/Zushah/Chalkboard/main/assets/Chalkboard-logo.png" width="50%"></a></p>
|
|
2
2
|
<p align="center">
|
|
3
|
-
<a href="https://www.github.com/Zushah/Chalkboard/releases/tag/v2.
|
|
4
|
-
<a href="https://www.
|
|
5
|
-
<a href="https://
|
|
3
|
+
<a href="https://www.github.com/Zushah/Chalkboard/releases/tag/v2.3.0"><img src="https://img.shields.io/badge/release-v2.3.0_Boole-blueviolet?logo=github&logoColor=white" alt="Latest release"></a>
|
|
4
|
+
<a href="https://www.github.com/microsoft/TypeScript"><img src="https://img.shields.io/github/languages/top/Zushah/Chalkboard?color=blue&logo=typescript&logoColor=white" alt="Written in TypeScript"></a>
|
|
5
|
+
<a href="https://www.codefactor.io/repository/github/zushah/chalkboard"><img src="https://img.shields.io/codefactor/grade/github/Zushah/Chalkboard?color=darkgreen&logo=codefactor&logoColor=white" alt="CodeFactor grade"></a>
|
|
6
6
|
<a href="https://www.npmjs.com/package/@zushah/chalkboard"><img src="https://img.shields.io/npm/dm/%40zushah/chalkboard?logo=npm&logoColor=white" alt="npm downloads"></a>
|
|
7
7
|
<a href="https://www.github.com/Zushah/Chalkboard/blob/main/LICENSE.md"><img src="https://img.shields.io/github/license/Zushah/Chalkboard?color=yellow&logo=opensourceinitiative&logoColor=white" alt="MIT License"></a>
|
|
8
|
-
<a href="https://
|
|
8
|
+
<a href="https://bundlephobia.com/package/@zushah/chalkboard@2.3.0"><img src="https://img.shields.io/bundlephobia/min/%40zushah/chalkboard?color=orange&logo=files&logoColor=white" alt="Minified size"></a>
|
|
9
9
|
<a href="https://www.jsdelivr.com/package/gh/Zushah/Chalkboard"><img src="https://img.shields.io/jsdelivr/gh/hm/Zushah/Chalkboard?color=crimson&logo=jsdelivr&logoColor=white" alt="jsDelivr requests"></a>
|
|
10
10
|
<br>
|
|
11
11
|
<a href="https://zushah.github.io/Chalkboard">https://zushah.github.io/Chalkboard</a>
|
|
@@ -23,28 +23,30 @@
|
|
|
23
23
|
</ol>
|
|
24
24
|
|
|
25
25
|
# About
|
|
26
|
-
The Chalkboard library is a JavaScript namespace that provides a plethora of both practical and abstract mathematical functionalities for its user. It was developed by [Zushah](https://www.github.com/Zushah) during 2022 and 2023 and then [released](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) on November 6, 2023. As per the latest release of [v2.
|
|
26
|
+
The Chalkboard library is a JavaScript namespace that provides a plethora of both practical and abstract mathematical functionalities for its user. It was developed by [Zushah](https://www.github.com/Zushah) during 2022 and 2023 and then [released](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) on November 6, 2023. As per the latest release of [v2.3.0 Boole](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.3.0), Chalkboard has 605 unique commands. The library is available for regular JavaScript on both the client-side and the server-side as well as [Proccesing.js](https://www.processing.org/) (fully compatible with [Khan Academy](https://www.khanacademy.org/cs/chalkboard/6708642430369792)). Chalkboard's website can be visited [here](https://zushah.github.io/Chalkboard).
|
|
27
27
|
|
|
28
28
|
# Installation
|
|
29
29
|
If your JavaScript project is being run on the client-side within a webpage, you can install Chalkboard with this HTML tag:
|
|
30
30
|
```html
|
|
31
|
-
<script src="https://cdn.jsdelivr.net/gh/Zushah/Chalkboard@2.
|
|
31
|
+
<script src="https://cdn.jsdelivr.net/gh/Zushah/Chalkboard@2.3.0/dist/Chalkboard.min.js"></script>
|
|
32
32
|
```
|
|
33
33
|
If your JavaScript project is being run on the server-side within the [Node.js](https://nodejs.org/en) environment, you can install Chalkboard with this console command:
|
|
34
34
|
```bash
|
|
35
35
|
npm install @zushah/chalkboard
|
|
36
36
|
```
|
|
37
|
-
Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.
|
|
37
|
+
Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.3.0) and put the relevant files in your project's directory.
|
|
38
38
|
|
|
39
39
|
Chalkboard can also be downloaded on [Khan Academy](https://www.khanacademy.org) from the code in the corresponding [release](https://www.khanacademy.org/cs/chalkboard/6708642430369792).
|
|
40
40
|
|
|
41
41
|
# Documentation
|
|
42
|
-
Chalkboard has
|
|
42
|
+
Chalkboard has fourteen categories of commands:
|
|
43
|
+
- `abal` - Abstract algebra definitions, sets, operations, structures, and morphisms
|
|
44
|
+
- `bool` - Boolean algebra operations
|
|
43
45
|
- `calc` - Single/multi-variable real/complex-valued calculus operations
|
|
44
46
|
- `comp` - Complex number and complex function operations
|
|
45
47
|
- `geom` - Geometric operations
|
|
46
48
|
- `matr` - Multidimensional matrix operations
|
|
47
|
-
- `numb` - Number-
|
|
49
|
+
- `numb` - Number-theoretic operations
|
|
48
50
|
- `plot` - Plotting real and complex functions, complex numbers, vectors, matrices, and statistical graphs
|
|
49
51
|
- `quat` - Quaternion operations
|
|
50
52
|
- `real` - Real number and real function operations
|
|
@@ -53,10 +55,11 @@ Chalkboard has twelve categories of commands:
|
|
|
53
55
|
- `trig` - Trigonometric function operations
|
|
54
56
|
- `vect` - Two-, three-, and four-dimensional vector and vector field operations
|
|
55
57
|
|
|
56
|
-
There are also
|
|
58
|
+
There are also nine "global" commands and constants, which are:
|
|
57
59
|
- `APPLY` - Applies a callback function in an element-wise manner on a Chalkboard object
|
|
58
60
|
- `CONTEXT` - The JavaScript canvas rendering context to use for plotting
|
|
59
61
|
- `E()` - Computes the number e
|
|
62
|
+
- `I()` - Computes the number i
|
|
60
63
|
- `LOGO()` - Draws the Chalkboard logo
|
|
61
64
|
- `PARSEPREFIX` - Used for adding custom functions to the Chalkboard parser
|
|
62
65
|
- `PI()` - Computes the number π
|
|
@@ -64,11 +67,15 @@ There are also eight "global" commands and constants, which are:
|
|
|
64
67
|
- `VERSION` - The installed version of Chalkboard
|
|
65
68
|
- `VERSIONALIAS` - The alias of the installed version of Chalkboard
|
|
66
69
|
|
|
67
|
-
Lastly, Chalkboard has
|
|
70
|
+
Lastly, Chalkboard has eleven data types (also known as Chalkboard objects):
|
|
68
71
|
- `ChalkboardComplex` - Complex numbers
|
|
69
72
|
- `ChalkboardFunction` - Mathematical functions
|
|
70
73
|
- `ChalkboardMatrix` - Matrices
|
|
74
|
+
- `ChalkboardMorphism` - Morphisms
|
|
71
75
|
- `ChalkboardQuaternion` - Quaternions
|
|
76
|
+
- `ChalkboardSet` - Sets
|
|
77
|
+
- `ChalkboardStructure` - Algebraic structures
|
|
78
|
+
- `ChalkboardStructureExtension` - Algebraic structure extensions
|
|
72
79
|
- `ChalkboardTensor` - Tensors
|
|
73
80
|
- `ChalkboardVector` - Vectors
|
|
74
81
|
- `ChalkboardVectorField` - Vector fields
|
|
@@ -83,51 +90,49 @@ Chalkboard.category.command(parameters);
|
|
|
83
90
|
Here is some code that shows off only a few features of Chalkboard:
|
|
84
91
|
```js
|
|
85
92
|
const cb = Chalkboard; // Initialize in a browser
|
|
86
|
-
// or
|
|
87
93
|
const cb = require("@zushah/chalkboard"); // Initialize in Node with CommonJS
|
|
88
|
-
// or
|
|
89
94
|
import cb from "@zushah/chalkboard"; // Initiialize in Node with ES Modules
|
|
90
95
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
const f = cb.real.define("Math.cos(2 * x)"); // f(x) = cos(2x)
|
|
97
|
+
const dfdx = cb.calc.dfdx(f, 2); // Derivative of f at x = 0
|
|
98
|
+
const fxdx = cb.calc.fxdx(f, 0, 2); // Antiderivative of f from x = 0 to x = 2
|
|
99
|
+
const fourier = cb.calc.Fourier(f, 2); // Fourier transform of f at x = 2
|
|
95
100
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
const f = cb.vect.field("x", "y", "z"); // f(x, y, z) = (x, y, z)
|
|
102
|
+
const r = cb.real.define(["Math.cos(s) * Math.cos(t)", "Math.sin(s) * Math.cos(t)", "Math.sin(t)"], "surf"); // r(s, t) = (cos(s)cos(t), sin(s)cos(t), sin(t))
|
|
103
|
+
const fnds = cb.calc.fnds(f, r, cb.PI(-1/2), cb.PI(1/2), 0, cb.PI(2)); // Flux of the radial vector field through the unit sphere
|
|
99
104
|
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
const primes = cb.numb.primeArr(0, 100); // Array of prime numbers between 0 and 100
|
|
106
|
+
const midPrime = cb.stat.median(primes); // Median number in the primes array
|
|
102
107
|
cb.plot.barplot(primes, cb.stat.array(0, 100, 11), {size: 5, strokeStyle: "black", fillStyle: "blue"}); // Barplot of the primes array with a bin size of 10, a scale of 2, a stroke color of black, and a fill color of blue
|
|
103
108
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
const z = cb.comp.init(1, 1); // z = 1 + i
|
|
110
|
+
const zsqsqrt = cb.comp.sqrt(cb.comp.sq(z)); // The square root of z squared equals z
|
|
111
|
+
const f = cb.comp.define("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1
|
|
107
112
|
cb.plot.definition(f); // Plots the domain coloring of f
|
|
108
113
|
|
|
109
|
-
|
|
114
|
+
const r = cb.real.define(["Math.cos(t)", "Math.sin(t)"], "curv"); // r(t) = (cos(t), sin(t))
|
|
110
115
|
cb.plot.xyplane({size: 2}); // Draws the Cartesian coordinate plane scaled by 2
|
|
111
116
|
cb.plot.definition(r, {size: 2, strokeStyle: "rgb(255, 100, 100)", domain: [0, cb.PI(2)]}); // Plots r(t) scaled by 2 colored light red from t = 0 to t = π/2
|
|
112
117
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
const a = cb.vect.init(1, 2, 3); // Vector a = (1, 2, 3)
|
|
119
|
+
const b = cb.vect.init(4, 5, 6); // Vector b = (4, 5, 6)
|
|
120
|
+
const c = cb.vect.init(7, 8, 9); // Vector c = (7, 8, 9)
|
|
121
|
+
const axbxc = cb.vect.vectorTriple(a, b, c); // Triple cross product between a, b, and c
|
|
117
122
|
cb.vect.print(axbxc); // Prints axbxc in the console
|
|
118
123
|
|
|
119
|
-
|
|
124
|
+
const m = cb.matr.init( // m is a 5x5 matrix
|
|
120
125
|
[0, 1, 1, 1, 1],
|
|
121
126
|
[1, 0, 1, 1, 1],
|
|
122
127
|
[1, 1, 0, 1, 1],
|
|
123
128
|
[1, 1, 1, 0, 1],
|
|
124
129
|
[1, 1, 1, 1, 0]
|
|
125
130
|
);
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
const mi = cb.matr.invert(m); // mi is the inverse of m
|
|
132
|
+
const mmi = cb.matr.mul(m, mi); // mmi is the product of m and mi
|
|
128
133
|
cb.matr.print(mmi); // Prints mmi in the console
|
|
129
134
|
|
|
130
|
-
|
|
135
|
+
const t = cb.tens.init( // t is a 2x2x2 rank-3 tensor
|
|
131
136
|
[
|
|
132
137
|
[1, 2],
|
|
133
138
|
[3, 4]
|
|
@@ -137,21 +142,23 @@ let t = cb.tens.init( // t is a 2x2x2 rank-3 tensor
|
|
|
137
142
|
[7, 8]
|
|
138
143
|
]
|
|
139
144
|
);
|
|
140
|
-
|
|
141
|
-
|
|
145
|
+
const tt = cb.tens.mul(t, t); // tt is a 2x2x2x2x2x2 rank-6 tensor
|
|
146
|
+
const ttm = cb.tens.resize(tt, 8, 8); // ttm is an 8x8 matrix (or rank-2 tensor)
|
|
142
147
|
cb.tens.print(tt); // Prints tt in the console just to see what it looks like for fun
|
|
148
|
+
const factorialt = cb.APPLY(t, (x) => cb.numb.factorial(x)); // Calculates the factorial of each element of t
|
|
143
149
|
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
150
|
+
const Z4 = cb.abal.Z(4); // The set of integers modulo 4 is the set {0, 1, 2, 3}
|
|
151
|
+
const C4 = cb.abal.C(4); // The set of fourth roots of unity is the set {1, i, -1, -i}
|
|
152
|
+
const G = cb.abal.group(Z4, (a, b) => (a + b) % 4); // The group G is the set Z₄ with mod 4 addition
|
|
153
|
+
const H = cb.abal.group(C4, (z, w) => cb.comp.mul(z, w)); // The group H is the set C₄ with complex multiplication
|
|
154
|
+
const F = cb.abal.isomorphism(G, H, (n) => cb.comp.round(cb.comp.pow(cb.comp.init(0, 1), n))); // The isomorphism F: G → H is defined by F(n) = iⁿ for all n in Z₄
|
|
148
155
|
```
|
|
149
|
-
|
|
156
|
+
Several examples that are rather interesting can be seen [here](https://zushah.github.io/Chalkboard/examples/index.html), and their source code is [here](https://www.github.com/Zushah/Chalkboard/tree/main/examples).
|
|
150
157
|
|
|
151
158
|
# Contributing
|
|
152
159
|
<ol>
|
|
153
160
|
<li>Fork Chalkboard's GitHub repository. Make sure the fork is based on the main branch.</li>
|
|
154
|
-
<li>Clone the repository, download the dependencies with `npm install`, and then make your contributions to your fork.</li>
|
|
161
|
+
<li>Clone the repository, download the dev dependencies with `npm install`, and then make your contributions to your fork.</li>
|
|
155
162
|
<li>When you're done, commit the changes to your fork with a detailed description.</li>
|
|
156
163
|
<li>Open a pull request. It will be reviewed soon and then merged to the main branch.</li>
|
|
157
164
|
</ol>
|
|
@@ -163,9 +170,9 @@ The changelog can be read [here](https://www.github.com/Zushah/Chalkboard/blob/m
|
|
|
163
170
|
The Chalkboard library is available under the [MIT License](https://www.github.com/Zushah/Chalkboard/blob/main/LICENSE.md).
|
|
164
171
|
|
|
165
172
|
# Acknowledgments
|
|
166
|
-
Thanks to [@bhavjitChauhan](https://www.github.com/bhavjitChauhan) for his [
|
|
167
|
-
Thanks to [@gyang0](https://www.github.com/gyang0) for his [
|
|
168
|
-
Thanks to [@JentGent](https://www.github.com/JentGent) for his [
|
|
173
|
+
Thanks to [@bhavjitChauhan](https://www.github.com/bhavjitChauhan) for his contribution ([here](https://www.github.com/Zushah/Chalkboard/pull/1)) to [v1.3.0 Heaviside](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0).\
|
|
174
|
+
Thanks to [@gyang0](https://www.github.com/gyang0) for his contributions ([here](https://www.github.com/Zushah/zushah.github.io/pull/1) and [here](https://github.com/Zushah/Chalkboard/pull/5)) to the [documentation](https://www.github.com/Zushah/zushah.github.io/tree/main/Chalkboard).\
|
|
175
|
+
Thanks to [@JentGent](https://www.github.com/JentGent) for his implementation ([here](https://www.github.com/JentGent/linalg/blob/main/linalg.js#L519)) for calculating QR decomposition which was [adapted](https://www.github.com/Zushah/Chalkboard/commit/1dce0dbac82b38f9a550dd496bc878c402a92442) into [v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0).
|
|
169
176
|
|
|
170
177
|
# Contact
|
|
171
178
|
[GitHub](https://www.github.com/Zushah)\
|