MCPcopy Index your code
hub / github.com/BrainJS/brain.js / matrixOrigin

Function matrixOrigin

browser.js:3935–3961  ·  view source on GitHub ↗
(m, stateIndex)

Source from the content-addressed store, hash-verified

3933 var jsonString = JSON.stringify(this.toJSON());
3934
3935 function matrixOrigin(m, stateIndex) {
3936 for (var i = 0, max = states.length; i < max; i++) {
3937 var state = states[i];
3938
3939 if (i === stateIndex) {
3940 var j = previousConnectionIndex(m);
3941 switch (m) {
3942 case state.left:
3943 if (j > -1) {
3944 return 'typeof prevStates[' + j + '] === \'object\' ? prevStates[' + j + '].product : new Matrix(' + m.rows + ', ' + m.columns + ')';
3945 }
3946 case state.right:
3947 if (j > -1) {
3948 return 'typeof prevStates[' + j + '] === \'object\' ? prevStates[' + j + '].product : new Matrix(' + m.rows + ', ' + m.columns + ')';
3949 }
3950 case state.product:
3951 return 'new Matrix(' + m.rows + ', ' + m.columns + ')';
3952 default:
3953 throw Error('unknown state');
3954 }
3955 }
3956
3957 if (m === state.product) return 'states[' + i + '].product';
3958 if (m === state.right) return 'states[' + i + '].right';
3959 if (m === state.left) return 'states[' + i + '].left';
3960 }
3961 }
3962
3963 function previousConnectionIndex(m) {
3964 var connection = model.equationConnections[0];

Callers 3

matrixToStringFunction · 0.85
matrixToStringMethod · 0.85
matrixToStringMethod · 0.85

Calls 1

previousConnectionIndexFunction · 0.85

Tested by

no test coverage detected