Created
January 17, 2017 18:27
-
-
Save dzolnai/ab629bfdac78d1b52a291ace05069bac to your computer and use it in GitHub Desktop.
Simplex solver article - gist 3
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
Type solutionVectorType = new Type.Builder(renderScript, Element.F32(renderScript)).setX(script.get_MAX_COLS()).create(); | |
Type resultSizeType = new Type.Builder(renderScript, Element.I32(renderScript)).create(); | |
script.set_solution_vector(arrayAllocation); | |
script.set_result_size(resultSizeAllocation); | |
script.invoke_solve(); | |
float[] solutionVector = new float[script.get_MAX_COLS()]; | |
arrayAllocation.copyTo(solutionVector); | |
int[] resultSizeVector = new int[1]; | |
resultSizeAllocation.copyTo(resultSizeVector); | |
// If the solution vector size is -1, no solution has been found. | |
if (resultSizeVector[0] <= 0) { | |
return null; | |
} | |
return Arrays.copyOf(solutionVector, resultSizeVector[0]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment