@zushah/chalkboard 1.7.0 → 2.0.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 CHANGED
@@ -1,6 +1,24 @@
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.0.0 al-Khwarizmi](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.0.0) - 01/08/2024
5
+ The tenth release of the Chalkboard library.
6
+ Commits: [`v1.7.0...v2.0.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.7.0...v2.0.0)
7
+ - Rewrote everything in TypeScript, applied ESLint and Prettier, and remade the website with TypeDoc
8
+ - Added `APPLY` which applies a callback function in an element-wise manner on a complex number, matrix, quaternion, tensor, or vector
9
+ - Added the `vect` category which merges the `vec2`, `vec3`, and `vec4` categories into one
10
+ - Added `VERSION` and `VERSIONALIAS` which return the installed version and its alias, respectively
11
+ - Removed the `vec2`, `vec3`, and `vec4` categories
12
+ - Removed `quat.fromVector` because it's been replaced by `vect.toQuaternion`
13
+ - Removed `plot.vec3` because it was weird
14
+ - Changed everything due to the TypeScript rewrite and the vector categories merge
15
+ - Changed all of the `.new` commands to be renamed as `.init`
16
+ - 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`
17
+ - Changed `LOGO` to draw the logo as a circle instead of a square
18
+ - Changed `matr.mulvec` to be renamed as `matr.mulVector`
19
+ - Fixed `matr.mulVector`` which didn't work when the rows of the matrix equaled the dimension of the vector
20
+ - 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)
21
+
4
22
  ## [v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0) - 01/01/2024
5
23
  The ninth release of the Chalkboard library.
6
24
  Commits: [`v1.6.0...v1.7.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.6.0...v1.7.0)
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
- <p align="center"><a href="https://www.github.com/Zushah/Chalkboard"><img src="./assets/Chalkboard-logo.png" width="50%"></a></p>
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/v1.7.0"><img src="https://img.shields.io/badge/release-v1.7.0_Descartes-blueviolet?logo=github&logoColor=white" alt="Latest release"></a>
3
+ <a href="https://www.github.com/Zushah/Chalkboard/releases/tag/v2.0.0"><img src="https://img.shields.io/badge/release-v2.0.0_al--Khwarizmi-blueviolet?logo=github&logoColor=white" alt="Latest release"></a>
4
4
  <a href="https://www.codefactor.io/repository/github/zushah/chalkboard"><img src="https://img.shields.io/codefactor/grade/github/Zushah/Chalkboard?color=blue&logo=codefactor&logoColor=white" alt="CodeFactor grade"></a>
5
- <a href="https://bundlephobia.com/package/@zushah/chalkboard@1.7.0"><img src="https://img.shields.io/bundlephobia/min/%40zushah/chalkboard?color=darkgreen&logo=files&logoColor=white" alt="Minified size"></a>
5
+ <a href="https://bundlephobia.com/package/@zushah/chalkboard@2.0.0"><img src="https://img.shields.io/bundlephobia/min/%40zushah/chalkboard?color=darkgreen&logo=files&logoColor=white" alt="Minified size"></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://en.wikipedia.org/wiki/JavaScript"><img src="https://img.shields.io/github/languages/top/Zushah/Chalkboard?color=orange&logo=javascript&logoColor=white" alt="Written in JavaScript"></a>
8
+ <a href="https://en.wikipedia.org/wiki/TypeScript"><img src="https://img.shields.io/github/languages/top/Zushah/Chalkboard?color=orange&logo=typescript&logoColor=white" alt="Written in TypeScript"></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
- <a href="https://zushah.github.io/Chalkboard/home.html">https://zushah.github.io/Chalkboard/home.html</a>
11
+ <a href="https://zushah.github.io/Chalkboard">https://zushah.github.io/Chalkboard</a>
12
12
  </p>
13
13
 
14
14
  # Contents
@@ -23,47 +23,57 @@
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 [v1.7.0 Descartes](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0), Chalkboard has 492 different 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/home.html).
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.0.0 al-Khwarizmi](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.0.0), Chalkboard has 410 different 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@1.7.0/src/Chalkboard.min.js"></script>
31
+ <script src="https://cdn.jsdelivr.net/gh/Zushah/Chalkboard@2.0.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
- npm install @zushah/chalkboard@1.7.0
35
+ npm install @zushah/chalkboard
36
36
  ```
37
- Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.7.0) and put the relevant files in your project's directory.
37
+ Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/v2.0.0) and put the relevant files in your project's directory.
38
38
 
39
- More methods and details about installing Chalkboard can be read [here](https://zushah.github.io/Chalkboard/installation.html).
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
- These are all fourteen Chalkboard categories with a brief description of what they're mostly about, and listed in the order they appear in the source code:
43
- - `numb` - Number-theory-related operations
44
- - `real` - Real number and real function operations
42
+ Chalkboard has twelve categories of commands:
43
+ - `calc` - Single/multi-variable real/complex-valued calculus operations
45
44
  - `comp` - Complex number and complex function operations
46
- - `quat` - Quaternion operations
45
+ - `geom` - Geometric operations
46
+ - `matr` - Multidimensional matrix operations
47
+ - `numb` - Number-theory-related operations
47
48
  - `plot` - Plotting real and complex functions, complex numbers, vectors, matrices, and statistical graphs
48
- - `geom` - Geometric formulae operations
49
- - `trig` - Trigonometric function operations
49
+ - `quat` - Quaternion operations
50
+ - `real` - Real number and real function operations
50
51
  - `stat` - Statistical array operations
51
- - `vec2` - Two-dimensional vector operations
52
- - `vec3` - Three-dimensional vector operations
53
- - `vec4` - Four-dimensional vector operations
54
- - `matr` - Multidimensional matrix operations
55
52
  - `tens` - Tensor (multidimensional multidimensional matrix) operations
56
- - `calc` - Single/multi-variable real/complex-valued calculus operations
53
+ - `trig` - Trigonometric function operations
54
+ - `vect` - Two-, three-, and four-dimensional vector and vector field operations
57
55
 
58
- There are also six "global" commands and constants in Chalkboard, which are:
59
- - `README()` - Prints basic information about Chalkboard in the console
60
- - `LOGO()` - Draws the Chalkboard logo
61
- - `PI()` - Computes the number π
62
- - `E()` - Computes the number e
56
+ There are also eight "global" commands and constants, which are:
57
+ - `APPLY` - Applies a callback function in an element-wise manner on a Chalkboard object
63
58
  - `CONTEXT` - The JavaScript canvas rendering context to use for plotting
59
+ - `E()` - Computes the number e
60
+ - `LOGO()` - Draws the Chalkboard logo
64
61
  - `PARSEPREFIX` - Used for adding custom functions to the Chalkboard parser
62
+ - `PI()` - Computes the number π
63
+ - `README()` - Prints basic information about Chalkboard in the console
64
+ - `VERSION` - The installed version of Chalkboard
65
+ - `VERSIONALIAS` - The alias of the installed version of Chalkboard
66
+
67
+ Lastly, Chalkboard has seven data types (also known as Chalkboard objects):
68
+ - `ChalkboardComplex` - Complex numbers
69
+ - `ChalkboardFunction` - Mathematical functions
70
+ - `ChalkboardMatrix` - Matrices
71
+ - `ChalkboardQuaternion` - Quaternions
72
+ - `ChalkboardTensor` - Tensors
73
+ - `ChalkboardVector` - Vectors
74
+ - `ChalkboardVectorField` - Vector fields
65
75
 
66
- The comprehensive Chalkboard documentation can be visited [here](https://zushah.github.io/Chalkboard/documentation.html).
76
+ The comprehensive Chalkboard documentation can be visited [here](https://zushah.github.io/Chalkboard).
67
77
 
68
78
  # Getting Started
69
79
  After installing Chalkboard into your program, you can immediately get started with using it. Every Chalkboard command begins with typing "Chalkboard" followed by a period, then the name of the category of the command (all categories are listed above in the [documentation](#documentation) section) with another period, and lastly the desired command itself.
@@ -78,67 +88,84 @@ const cb = require("@zushah/chalkboard"); // Initialize in Node with CommonJS
78
88
  // or
79
89
  import cb from "@zushah/chalkboard"; // Initiialize in Node with ES Modules
80
90
 
81
- let f = cb.real.function("Math.cos(2 * x)"); // f(x) = cos(2x)
91
+ let f = cb.real.define("Math.cos(2 * x)"); // f(x) = cos(2x)
82
92
  let dfdx = cb.calc.dfdx(f, 2); // Derivative of f at x = 0
83
93
  let fxdx = cb.calc.fxdx(f, 0, 2); // Antiderivative of f from x = 0 to x = 2
84
94
  let fourier = cb.calc.Fourier(f, 2); // Fourier transform of f at x = 2
85
95
 
86
96
  let f = cb.vec3.field("x", "y", "z"); // f(x, y, z) = (x, y, z)
87
- let r = cb.real.function(["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))
97
+ let 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))
88
98
  let 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
89
99
 
90
100
  let primes = cb.numb.primeArr(0, 100); // Array of prime numbers between 0 and 100
91
101
  let midPrime = cb.stat.median(primes); // Median number in the primes array
92
102
  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
93
103
 
94
- let z = cb.comp.new(1, 1); // z = 1 + i
104
+ let z = cb.comp.init(1, 1); // z = 1 + i
95
105
  let zsqsqrt = cb.comp.sqrt(cb.comp.sq(z)); // The square root of z squared equals z
96
- let f = cb.comp.function("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1
97
- cb.plot.function(f); // Plots the domain coloring of f
106
+ let f = cb.comp.define("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1
107
+ cb.plot.definition(f); // Plots the domain coloring of f
98
108
 
99
- let r = cb.real.function(["Math.cos(t)", "Math.sin(t)"], "curv"); // r(t) = (cos(t), sin(t))
109
+ let r = cb.real.define(["Math.cos(t)", "Math.sin(t)"], "curv"); // r(t) = (cos(t), sin(t))
100
110
  cb.plot.xyplane({size: 2}); // Draws the Cartesian coordinate plane scaled by 2
101
- cb.plot.function(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
102
-
103
- let a = cb.vec3.new(1, 2, 3); // Vector a = (1, 2, 3)
104
- let b = cb.vec3.new(4, 5, 6); // Vector b = (4, 5, 6)
105
- let c = cb.vec3.new(7, 8, 9); // Vector c = (7, 8, 9)
106
- let axbxc = cb.vec3.vectorTriple(a, b, c); // Triple cross product between a, b, and c
107
- cb.vec3.print(axbxc); // Prints axbxc in the console
108
-
109
- let m = cb.matr.new([0, 1, 1, 1, 1], // m is a 5x5 matrix
110
- [1, 0, 1, 1, 1],
111
- [1, 1, 0, 1, 1],
112
- [1, 1, 1, 0, 1],
113
- [1, 1, 1, 1, 0]);
111
+ 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
+
113
+ let a = cb.vect.init(1, 2, 3); // Vector a = (1, 2, 3)
114
+ let b = cb.vect.init(4, 5, 6); // Vector b = (4, 5, 6)
115
+ let c = cb.vect.init(7, 8, 9); // Vector c = (7, 8, 9)
116
+ let axbxc = cb.vect.vectorTriple(a, b, c); // Triple cross product between a, b, and c
117
+ cb.vect.print(axbxc); // Prints axbxc in the console
118
+
119
+ let m = cb.matr.init( // m is a 5x5 matrix
120
+ [0, 1, 1, 1, 1],
121
+ [1, 0, 1, 1, 1],
122
+ [1, 1, 0, 1, 1],
123
+ [1, 1, 1, 0, 1],
124
+ [1, 1, 1, 1, 0]
125
+ );
114
126
  let mi = cb.matr.invert(m); // mi is the inverse of m
115
127
  let mmi = cb.matr.mul(m, mi); // mmi is the product of m and mi
116
128
  cb.matr.print(mmi); // Prints mmi in the console
117
129
 
118
- let t = cb.tens.new([[1, 2], [3, 4]], // t is a 2x2x2 (rank-3) tensor
119
- [[5, 6], [7, 8]]);
120
- let tt = cb.tens.mul(t, t); // tt is a 2x2x2x2x2x2 (rank-6) tensor
130
+ let t = cb.tens.init( // t is a 2x2x2 rank-3 tensor
131
+ [
132
+ [1, 2],
133
+ [3, 4]
134
+ ],
135
+ [
136
+ [5, 6],
137
+ [7, 8]
138
+ ]
139
+ );
140
+ let tt = cb.tens.mul(t, t); // tt is a 2x2x2x2x2x2 rank-6 tensor
121
141
  let ttm = cb.tens.resize(tt, 8, 8); // ttm is an 8x8 matrix (or rank-2 tensor)
122
142
  cb.tens.print(tt); // Prints tt in the console just to see what it looks like for fun
143
+
144
+ // Takes the factorial of each element of t
145
+ let factorialt = cb.APPLY(t, (x) => {
146
+ return cb.numb.factorial(x);
147
+ });
123
148
  ```
124
- More examples that are more interesting can be seen [here](https://zushah.github.io/Chalkboard/examples.html) with their source code [here](https://www.github.com/Zushah/Chalkboard/tree/main/examples).
149
+ More examples that are more interesting can be seen [here](https://zushah.github.io/Chalkboard/examples/index.html) with their source code [here](https://www.github.com/Zushah/Chalkboard/tree/main/examples).
125
150
 
126
151
  # Contributing
127
152
  <ol>
128
153
  <li>Fork Chalkboard's GitHub repository. Make sure the fork is based on the main branch.</li>
129
- <li>Make your contributions to your fork. If you're adding new features or modifying the functionalities of old ones, please make sure you do the same for both editions (JavaScript and Processing.js) of the library.</li>
154
+ <li>Clone the repository, download the dependencies with `npm install`, and then make your contributions to your fork.</li>
130
155
  <li>When you're done, commit the changes to your fork with a detailed description.</li>
131
156
  <li>Open a pull request. It will be reviewed soon and then merged to the main branch.</li>
132
157
  </ol>
133
158
 
159
+ NOTE: If you want to change the documentation, you will also have to clone the [zushah.github.io repository](https://www.github.com/Zushah/zushah.github.io) because that's where the files are generated.
160
+
134
161
  The changelog can be read [here](https://www.github.com/Zushah/Chalkboard/blob/main/CHANGELOG.md).
135
162
 
136
163
  The Chalkboard library is available under the [MIT License](https://www.github.com/Zushah/Chalkboard/blob/main/LICENSE.md).
137
164
 
138
165
  # Acknowledgments
139
- Thanks to [Bhavjit Chauhan](https://www.github.com/bhavjitChauhan) for his [contribution](https://www.github.com/Zushah/Chalkboard/pull/1) to [v1.3.0 Heaviside](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0).\
140
- Thanks to [G. Yang](https://www.github.com/gyang0) for his [contribution](https://www.github.com/Zushah/zushah.github.io/pull/1) to the [documentation](https://www.github.com/Zushah/zushah.github.io/tree/main/Chalkboard).\
141
- Thanks to [JentGent](https://www.github.com/JentGent) for his [implementation](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).
166
+ Thanks to [@bhavjitChauhan](https://www.github.com/bhavjitChauhan) for his [contribution](https://www.github.com/Zushah/Chalkboard/pull/1) to [v1.3.0 Heaviside](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0).\
167
+ Thanks to [@gyang0](https://www.github.com/gyang0) for his [contribution](https://www.github.com/Zushah/zushah.github.io/pull/1) to the [documentation](https://www.github.com/Zushah/zushah.github.io/tree/main/Chalkboard).\
168
+ Thanks to [@JentGent](https://www.github.com/JentGent) for his [implementation](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).
142
169
 
143
170
  # Contact
144
171
  [GitHub](https://www.github.com/Zushah)\