Skip to content

Commit

Permalink
Special treatment for exponents 0 and 1
Browse files Browse the repository at this point in the history
  • Loading branch information
montaga committed Feb 20, 2017
1 parent 4bf17cc commit 806d038
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/cindygl/src/js/WebGL.js
Expand Up @@ -560,7 +560,9 @@ webgl["complex"] = first([
]);

let createraise = (k, codebuilder) => {
if (k == 2) {
if (k <= 1) {
return;
} else if (k == 2) {
codebuilder.add('functions', 'raise2', () => `float raise2(float a) { return a*a; }`);
} else {

Expand All @@ -570,7 +572,7 @@ let createraise = (k, codebuilder) => {
codebuilder.add('functions', name, () => `float ${name}(float a) { return ${raise('a', k)};}`);
}
}
let useraise = k => ((args, modifs, codebuilder) => createraise(k, codebuilder) || `raise${k}(${args[0]})`);
let useraise = k => ((args, modifs, codebuilder) => k == 0 ? '1.' : k == 1 ? args[0] : createraise(k, codebuilder) || `raise${k}(${args[0]})`);

webgl["pow"] = args => {
if (isconstantint(args[1]) && issubtypeof(args[0], type.float)) {
Expand Down

0 comments on commit 806d038

Please sign in to comment.