Skip to content

Commit f7bd96d

Browse files
committed
reorganize code
1 parent 7eba2e9 commit f7bd96d

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

fdg.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict'
22

3+
var dup = require('dup')
4+
35
var CACHED_CWiseOp = {
46
zero: function(SS, a0, t0, p0) {
57
var s0 = SS[0], t0p0 = t0[0]
@@ -43,12 +45,6 @@ var CACHED_CWiseOp = {
4345
}
4446
}
4547

46-
function generateCWiseOp(proc) {
47-
return CACHED_CWiseOp[proc.funcName]
48-
}
49-
50-
var compile = generateCWiseOp
51-
5248
var CACHED_thunk = {
5349
cdiff: function(compile) {
5450
var CACHED = {}
@@ -100,6 +96,10 @@ function createThunk(proc) {
10096
return thunk(compile.bind(undefined, proc))
10197
}
10298

99+
function compile(proc) {
100+
return CACHED_CWiseOp[proc.funcName]
101+
}
102+
103103
function Procedure() {
104104
this.argTypes = []
105105
this.shimArgs = []
@@ -116,7 +116,7 @@ function Procedure() {
116116
this.post = null
117117
}
118118

119-
function compileCwise(user_args) {
119+
function cwiseCompiler(user_args) {
120120
//Create procedure
121121
var proc = new Procedure()
122122

@@ -156,11 +156,6 @@ function compileCwise(user_args) {
156156
}
157157

158158

159-
module.exports = gradient
160-
161-
var dup = require('dup')
162-
var cwiseCompiler = compileCwise
163-
164159
var TEMPLATE_CACHE = {}
165160
var GRADIENT_CACHE = {}
166161

@@ -390,7 +385,7 @@ function generateGradient(boundaryConditions) {
390385
return proc
391386
}
392387

393-
function gradient(out, inp, bc) {
388+
module.exports = function gradient(out, inp, bc) {
394389
if(!Array.isArray(bc)) {
395390
if(typeof bc === 'string') {
396391
bc = dup(inp.dimension, bc)

0 commit comments

Comments
 (0)