-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34d47e0
commit d0d3481
Showing
4 changed files
with
72 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,18 @@ | ||
import {largestAbsoluteMovedToTopOfColumn} from './largestAbsoluteMovedToTopOfColumn' | ||
import {zeroAllRowsUnderThePivot} from './zeroAllRowsUnderThePivot' | ||
import {scalePivotToOne} from './scalePivotToOne' | ||
import {pivotValueIsOne} from './pivotValueIsOne' | ||
import {largestAbsoluteMovedToTopOfColumn} from './largestAbsoluteMovedToTopOfColumn'; | ||
import {zeroAllRowsUnderThePivot} from './zeroAllRowsUnderThePivot'; | ||
import {scalePivotToOne} from './scalePivotToOne'; | ||
import {findNextPivot} from './findNextPivot'; | ||
|
||
export function changeToEtchlonForm(system){ | ||
let newSystem = { ...system }; | ||
console.log("pivotValueIsOne"); | ||
console.log(pivotValueIsOne); | ||
const valueIsOne = pivotValueIsOne(newSystem); | ||
if ( ! valueIsOne) { | ||
newSystem = scalePivotToOne(newSystem); | ||
} | ||
if (newSystem.s.length - 1 == newSystem.pivot.row) { | ||
return newSystem | ||
const lastSystem = scalePivotToOne(newSystem); | ||
return lastSystem; | ||
}else { | ||
const systemLargestTop = largestAbsoluteMovedToTopOfColumn(newSystem); | ||
const zeroedUnderPivot = zeroAllRowsUnderThePivot(systemLargestTop); | ||
const { pivot, ...zeroedUnderPivotPostIteration } = zeroedUnderPivot; | ||
zeroedUnderPivotPostIteration.pivot = { | ||
row : zeroedUnderPivot.pivot.row + 1, | ||
column : zeroedUnderPivot.pivot.column + 1 | ||
}; | ||
return changeToEtchlonForm(zeroedUnderPivotPostIteration); | ||
const scaled = scalePivotToOne(zeroedUnderPivot); | ||
const nextSystem = findNextPivot(scaled); | ||
return changeToEtchlonForm(nextSystem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function findNextPivot(system) { | ||
const { pivot, ...nextSystem } = system; | ||
nextSystem.pivot = { | ||
row : pivot.row + 1, | ||
column : pivot.column + 1 | ||
}; | ||
return nextSystem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters