Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Add additional matrix constructors that take a flattened list of scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
litherum committed Aug 16, 2019
1 parent ad6ce5e commit 22906ea
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Spec/source/Generate_Standard_Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ for (let type of [`bool`, `uint`, `int`, `float`]) {
print();

for (let type of [`float`]) {
let variables = [`a`, `b`, `c`, `d`];
let variables = [`a`, `b`, `c`, `d`, `e`, `f`, `g`, `h`, `i`, `j`, `k`, `l`, `m`, `n`, `o`, `p`];
for (let m of [2, 3, 4]) {
for (let n of [2, 3, 4]) {
let signature = `operator ${type}${m}x${n}(`;
Expand All @@ -461,6 +461,35 @@ for (let type of [`float`]) {
}
print(` return result;`);
print(`}`);

signature = `operator ${type}${m}x${n}(`;
for (let i = 0; i < m; ++i) {
for (let j = 0; j < n; ++j) {
if (i != 0 || j != 0) {
signature += `, `;
}
signature += `${type} ${variables[4 * i + j]}`;
}
}
signature += `) {`;
print(signature);
let line = ` return ${type}${m}x${n}(`;
for (let i = 0; i < m; ++i) {
if (i != 0) {
line += `, `;
}
line += `${type}${n}(`;
for (let j = 0; j < n; ++j) {
if (j != 0) {
line += `, `;
}
line += `${variables[4 * i + j]}`;
}
line += `)`;
}
line += ");"
print(line);
print(`}`);
}
}
}
Expand Down

0 comments on commit 22906ea

Please sign in to comment.