Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,21 @@ <h2>Random arrays</h2>
<input class="btn" name="randomSize" id="randomSize" placeholder="size" size="10" type="number" />
</p>

<hr />
<h2>Linear Algebra</h2>

<p>
<input type="button" class="btn btn-column" value="dot" onclick="dotAlgebra();" />
<input type="button" class="btn btn-column" value="@" onclick="symbolAlgebra(this.value);" />
<input type="button" class="btn btn-column" value="." onclick="symbolAlgebra(this.value);" />
</p>

<p>
<input class="btn" name="arrayA" id="arrayA" placeholder="array A" size="10" type="textfield" />
<input class="btn" name="arrayB" id="arrayB" placeholder="array B" size="10" type="textfield" />

</p>

</div>
</td>
<td id="textbox">
Expand Down
26 changes: 26 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,29 @@ const randomSizeFunc = () => {
document.editor.textbox.value+="\n" + variable.value + " = np.random.randint(" + randomValue.value + ", size=" + randomSize.value + ")";
}
}

// Linear Algebra
let arrayA = document.getElementById("arrayA");
let arrayB = document.getElementById("arrayB");

const dotAlgebra = () => {
if (arrayA.value === '') {
return alert("Please enter an array reference in the 'array A' field, in the 'Linear Algebra' section.");
} else if (arrayB.value === "") {
return alert("Please enter an array reference in the 'array B' field, in the 'Linear Algebra' section.");
} else {
document.editor.textbox.value+="\n" + arrayA.value + ".dot(" + arrayB.value + ")";
}
}

const symbolAlgebra = (arg) => {
if (arrayA.value === "") {
return alert("Please enter an array reference in the 'array A' field, in the 'Linear Algebra' section.");
} else if (arrayB.value == "") {
return alert("Please enter an array reference in the 'array B' field, in the 'Linear Algebra' section.");
} else if (arg === ".") {
document.editor.textbox.value+="\n" + arrayA.value + arg + arrayB.value;
} else {
document.editor.textbox.value+="\n" + arrayA.value + " " + arg + " " + arrayB.value;
}
}
10 changes: 10 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ td {
border-color: rgb(70, 30, 255);
}

.btn-column {
background: orange;
border-color: darkOrange;
}

.btn-column:hover {
background: darkOrange;
border-color: chocolate;
}

/* input */

input {
Expand Down