repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
Harium/keel
src/main/java/com/harium/keel/effect/height/Sobel.java
Sobel.apply
@Override public ImageSource apply(ImageSource input) { final int[][] pixelMatrix = new int[3][3]; int w = input.getWidth(); int h = input.getHeight(); int[][] output = new int[h][w]; for (int j = 1; j < h - 1; j++) { for (int i = 1; i < w - 1; i++) { pixelMatrix[0][0] = input.getR(i - 1, j - 1); pixelMatrix[0][1] = input.getRGB(i - 1, j); pixelMatrix[0][2] = input.getRGB(i - 1, j + 1); pixelMatrix[1][0] = input.getRGB(i, j - 1); pixelMatrix[1][2] = input.getRGB(i, j + 1); pixelMatrix[2][0] = input.getRGB(i + 1, j - 1); pixelMatrix[2][1] = input.getRGB(i + 1, j); pixelMatrix[2][2] = input.getRGB(i + 1, j + 1); int edge = (int) convolution(pixelMatrix); int rgb = (edge << 16 | edge << 8 | edge); output[j][i] = rgb; } } MatrixSource source = new MatrixSource(output); return source; }
java
@Override public ImageSource apply(ImageSource input) { final int[][] pixelMatrix = new int[3][3]; int w = input.getWidth(); int h = input.getHeight(); int[][] output = new int[h][w]; for (int j = 1; j < h - 1; j++) { for (int i = 1; i < w - 1; i++) { pixelMatrix[0][0] = input.getR(i - 1, j - 1); pixelMatrix[0][1] = input.getRGB(i - 1, j); pixelMatrix[0][2] = input.getRGB(i - 1, j + 1); pixelMatrix[1][0] = input.getRGB(i, j - 1); pixelMatrix[1][2] = input.getRGB(i, j + 1); pixelMatrix[2][0] = input.getRGB(i + 1, j - 1); pixelMatrix[2][1] = input.getRGB(i + 1, j); pixelMatrix[2][2] = input.getRGB(i + 1, j + 1); int edge = (int) convolution(pixelMatrix); int rgb = (edge << 16 | edge << 8 | edge); output[j][i] = rgb; } } MatrixSource source = new MatrixSource(output); return source; }
[ "@", "Override", "public", "ImageSource", "apply", "(", "ImageSource", "input", ")", "{", "final", "int", "[", "]", "[", "]", "pixelMatrix", "=", "new", "int", "[", "3", "]", "[", "3", "]", ";", "int", "w", "=", "input", ".", "getWidth", "(", ")", ";", "int", "h", "=", "input", ".", "getHeight", "(", ")", ";", "int", "[", "]", "[", "]", "output", "=", "new", "int", "[", "h", "]", "[", "w", "]", ";", "for", "(", "int", "j", "=", "1", ";", "j", "<", "h", "-", "1", ";", "j", "++", ")", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<", "w", "-", "1", ";", "i", "++", ")", "{", "pixelMatrix", "[", "0", "]", "[", "0", "]", "=", "input", ".", "getR", "(", "i", "-", "1", ",", "j", "-", "1", ")", ";", "pixelMatrix", "[", "0", "]", "[", "1", "]", "=", "input", ".", "getRGB", "(", "i", "-", "1", ",", "j", ")", ";", "pixelMatrix", "[", "0", "]", "[", "2", "]", "=", "input", ".", "getRGB", "(", "i", "-", "1", ",", "j", "+", "1", ")", ";", "pixelMatrix", "[", "1", "]", "[", "0", "]", "=", "input", ".", "getRGB", "(", "i", ",", "j", "-", "1", ")", ";", "pixelMatrix", "[", "1", "]", "[", "2", "]", "=", "input", ".", "getRGB", "(", "i", ",", "j", "+", "1", ")", ";", "pixelMatrix", "[", "2", "]", "[", "0", "]", "=", "input", ".", "getRGB", "(", "i", "+", "1", ",", "j", "-", "1", ")", ";", "pixelMatrix", "[", "2", "]", "[", "1", "]", "=", "input", ".", "getRGB", "(", "i", "+", "1", ",", "j", ")", ";", "pixelMatrix", "[", "2", "]", "[", "2", "]", "=", "input", ".", "getRGB", "(", "i", "+", "1", ",", "j", "+", "1", ")", ";", "int", "edge", "=", "(", "int", ")", "convolution", "(", "pixelMatrix", ")", ";", "int", "rgb", "=", "(", "edge", "<<", "16", "|", "edge", "<<", "8", "|", "edge", ")", ";", "output", "[", "j", "]", "[", "i", "]", "=", "rgb", ";", "}", "}", "MatrixSource", "source", "=", "new", "MatrixSource", "(", "output", ")", ";", "return", "source", ";", "}" ]
Expects a height mat as input @param input - A grayscale height map @return edges
[ "Expects", "a", "height", "mat", "as", "input" ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/effect/height/Sobel.java#L19-L47
train
skuzzle/jeve
jeve/src/main/java/de/skuzzle/jeve/providers/EventStackImpl.java
EventStackImpl.popEvent
public <L extends Listener> void popEvent(Event<?, L> expected) { synchronized (this.stack) { final Event<?, ?> actual = this.stack.pop(); if (actual != expected) { throw new IllegalStateException(String.format( "Unbalanced pop: expected '%s' but encountered '%s'", expected.getListenerClass(), actual)); } } }
java
public <L extends Listener> void popEvent(Event<?, L> expected) { synchronized (this.stack) { final Event<?, ?> actual = this.stack.pop(); if (actual != expected) { throw new IllegalStateException(String.format( "Unbalanced pop: expected '%s' but encountered '%s'", expected.getListenerClass(), actual)); } } }
[ "public", "<", "L", "extends", "Listener", ">", "void", "popEvent", "(", "Event", "<", "?", ",", "L", ">", "expected", ")", "{", "synchronized", "(", "this", ".", "stack", ")", "{", "final", "Event", "<", "?", ",", "?", ">", "actual", "=", "this", ".", "stack", ".", "pop", "(", ")", ";", "if", "(", "actual", "!=", "expected", ")", "{", "throw", "new", "IllegalStateException", "(", "String", ".", "format", "(", "\"Unbalanced pop: expected '%s' but encountered '%s'\"", ",", "expected", ".", "getListenerClass", "(", ")", ",", "actual", ")", ")", ";", "}", "}", "}" ]
Pops the top event off the current event stack. This action has to be performed immediately after the event has been dispatched to all listeners. @param <L> Type of the listener. @param expected The Event which is expected at the top of the stack. @see #pushEvent(Event)
[ "Pops", "the", "top", "event", "off", "the", "current", "event", "stack", ".", "This", "action", "has", "to", "be", "performed", "immediately", "after", "the", "event", "has", "been", "dispatched", "to", "all", "listeners", "." ]
42cc18947c9c8596c34410336e4e375e9fcd7c47
https://github.com/skuzzle/jeve/blob/42cc18947c9c8596c34410336e4e375e9fcd7c47/jeve/src/main/java/de/skuzzle/jeve/providers/EventStackImpl.java#L114-L123
train
skuzzle/jeve
jeve/src/main/java/de/skuzzle/jeve/stores/AbstractSynchronizedListenerSource.java
AbstractSynchronizedListenerSource.modify
protected void modify(Transaction t) { try { this.lock.writeLock().lock(); t.perform(); } finally { this.lock.writeLock().unlock(); } }
java
protected void modify(Transaction t) { try { this.lock.writeLock().lock(); t.perform(); } finally { this.lock.writeLock().unlock(); } }
[ "protected", "void", "modify", "(", "Transaction", "t", ")", "{", "try", "{", "this", ".", "lock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "t", ".", "perform", "(", ")", ";", "}", "finally", "{", "this", ".", "lock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
Executes the given transaction within the context of a write lock. @param t The transaction to execute.
[ "Executes", "the", "given", "transaction", "within", "the", "context", "of", "a", "write", "lock", "." ]
42cc18947c9c8596c34410336e4e375e9fcd7c47
https://github.com/skuzzle/jeve/blob/42cc18947c9c8596c34410336e4e375e9fcd7c47/jeve/src/main/java/de/skuzzle/jeve/stores/AbstractSynchronizedListenerSource.java#L48-L55
train
skuzzle/jeve
jeve/src/main/java/de/skuzzle/jeve/stores/AbstractSynchronizedListenerSource.java
AbstractSynchronizedListenerSource.read
protected <E> E read(Supplier<E> sup) { try { this.lock.readLock().lock(); return sup.get(); } finally { this.lock.readLock().unlock(); } }
java
protected <E> E read(Supplier<E> sup) { try { this.lock.readLock().lock(); return sup.get(); } finally { this.lock.readLock().unlock(); } }
[ "protected", "<", "E", ">", "E", "read", "(", "Supplier", "<", "E", ">", "sup", ")", "{", "try", "{", "this", ".", "lock", ".", "readLock", "(", ")", ".", "lock", "(", ")", ";", "return", "sup", ".", "get", "(", ")", ";", "}", "finally", "{", "this", ".", "lock", ".", "readLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
Executes the given supplier within the context of a read lock. @param <E> The result type. @param sup The supplier. @return The result of {@link Supplier#get()}.
[ "Executes", "the", "given", "supplier", "within", "the", "context", "of", "a", "read", "lock", "." ]
42cc18947c9c8596c34410336e4e375e9fcd7c47
https://github.com/skuzzle/jeve/blob/42cc18947c9c8596c34410336e4e375e9fcd7c47/jeve/src/main/java/de/skuzzle/jeve/stores/AbstractSynchronizedListenerSource.java#L64-L71
train
vnesek/nmote-iim4j
src/main/java/com/nmote/iim4j/stream/SubIIMInputStream.java
SubIIMInputStream.setOffsetAndLength
protected void setOffsetAndLength(long offset, int length) throws IOException { this.offset = offset; this.length = length; this.position = 0; if (subStream.position() != offset) { subStream.seek(offset); } }
java
protected void setOffsetAndLength(long offset, int length) throws IOException { this.offset = offset; this.length = length; this.position = 0; if (subStream.position() != offset) { subStream.seek(offset); } }
[ "protected", "void", "setOffsetAndLength", "(", "long", "offset", ",", "int", "length", ")", "throws", "IOException", "{", "this", ".", "offset", "=", "offset", ";", "this", ".", "length", "=", "length", ";", "this", ".", "position", "=", "0", ";", "if", "(", "subStream", ".", "position", "(", ")", "!=", "offset", ")", "{", "subStream", ".", "seek", "(", "offset", ")", ";", "}", "}" ]
This should be called from a subclass constructor, if offset or length are unknown at a time when SubIIMInputStream constructor is called. This method shouldn't be called more than once. @param offset byte offset @param length byte length @throws IOException if underlying stream can't be read
[ "This", "should", "be", "called", "from", "a", "subclass", "constructor", "if", "offset", "or", "length", "are", "unknown", "at", "a", "time", "when", "SubIIMInputStream", "constructor", "is", "called", ".", "This", "method", "shouldn", "t", "be", "called", "more", "than", "once", "." ]
ec55b02fc644cd722e93051ac0bdb96b00cb42a8
https://github.com/vnesek/nmote-iim4j/blob/ec55b02fc644cd722e93051ac0bdb96b00cb42a8/src/main/java/com/nmote/iim4j/stream/SubIIMInputStream.java#L64-L72
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Bessel.java
Bessel.J0
public static double J0(double x) { double ax; if ((ax = Math.abs(x)) < 8.0) { double y = x * x; double ans1 = 57568490574.0 + y * (-13362590354.0 + y * (651619640.7 + y * (-11214424.18 + y * (77392.33017 + y * (-184.9052456))))); double ans2 = 57568490411.0 + y * (1029532985.0 + y * (9494680.718 + y * (59272.64853 + y * (267.8532712 + y * 1.0)))); return ans1 / ans2; } else { double z = 8.0 / ax; double y = z * z; double xx = ax - 0.785398164; double ans1 = 1.0 + y * (-0.1098628627e-2 + y * (0.2734510407e-4 + y * (-0.2073370639e-5 + y * 0.2093887211e-6))); double ans2 = -0.1562499995e-1 + y * (0.1430488765e-3 + y * (-0.6911147651e-5 + y * (0.7621095161e-6 - y * 0.934935152e-7))); return Math.sqrt(0.636619772 / ax) * (Math.cos(xx) * ans1 - z * Math.sin(xx) * ans2); } }
java
public static double J0(double x) { double ax; if ((ax = Math.abs(x)) < 8.0) { double y = x * x; double ans1 = 57568490574.0 + y * (-13362590354.0 + y * (651619640.7 + y * (-11214424.18 + y * (77392.33017 + y * (-184.9052456))))); double ans2 = 57568490411.0 + y * (1029532985.0 + y * (9494680.718 + y * (59272.64853 + y * (267.8532712 + y * 1.0)))); return ans1 / ans2; } else { double z = 8.0 / ax; double y = z * z; double xx = ax - 0.785398164; double ans1 = 1.0 + y * (-0.1098628627e-2 + y * (0.2734510407e-4 + y * (-0.2073370639e-5 + y * 0.2093887211e-6))); double ans2 = -0.1562499995e-1 + y * (0.1430488765e-3 + y * (-0.6911147651e-5 + y * (0.7621095161e-6 - y * 0.934935152e-7))); return Math.sqrt(0.636619772 / ax) * (Math.cos(xx) * ans1 - z * Math.sin(xx) * ans2); } }
[ "public", "static", "double", "J0", "(", "double", "x", ")", "{", "double", "ax", ";", "if", "(", "(", "ax", "=", "Math", ".", "abs", "(", "x", ")", ")", "<", "8.0", ")", "{", "double", "y", "=", "x", "*", "x", ";", "double", "ans1", "=", "57568490574.0", "+", "y", "*", "(", "-", "13362590354.0", "+", "y", "*", "(", "651619640.7", "+", "y", "*", "(", "-", "11214424.18", "+", "y", "*", "(", "77392.33017", "+", "y", "*", "(", "-", "184.9052456", ")", ")", ")", ")", ")", ";", "double", "ans2", "=", "57568490411.0", "+", "y", "*", "(", "1029532985.0", "+", "y", "*", "(", "9494680.718", "+", "y", "*", "(", "59272.64853", "+", "y", "*", "(", "267.8532712", "+", "y", "*", "1.0", ")", ")", ")", ")", ";", "return", "ans1", "/", "ans2", ";", "}", "else", "{", "double", "z", "=", "8.0", "/", "ax", ";", "double", "y", "=", "z", "*", "z", ";", "double", "xx", "=", "ax", "-", "0.785398164", ";", "double", "ans1", "=", "1.0", "+", "y", "*", "(", "-", "0.1098628627e-2", "+", "y", "*", "(", "0.2734510407e-4", "+", "y", "*", "(", "-", "0.2073370639e-5", "+", "y", "*", "0.2093887211e-6", ")", ")", ")", ";", "double", "ans2", "=", "-", "0.1562499995e-1", "+", "y", "*", "(", "0.1430488765e-3", "+", "y", "*", "(", "-", "0.6911147651e-5", "+", "y", "*", "(", "0.7621095161e-6", "-", "y", "*", "0.934935152e-7", ")", ")", ")", ";", "return", "Math", ".", "sqrt", "(", "0.636619772", "/", "ax", ")", "*", "(", "Math", ".", "cos", "(", "xx", ")", "*", "ans1", "-", "z", "*", "Math", ".", "sin", "(", "xx", ")", "*", "ans2", ")", ";", "}", "}" ]
Bessel function of order 0. @param x Value. @return J0 value.
[ "Bessel", "function", "of", "order", "0", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Bessel.java#L66-L90
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Bessel.java
Bessel.J
public static double J(int n, double x) { int j, m; double ax, bj, bjm, bjp, sum, tox, ans; boolean jsum; double ACC = 40.0; double BIGNO = 1.0e+10; double BIGNI = 1.0e-10; if (n == 0) return J0(x); if (n == 1) return J(x); ax = Math.abs(x); if (ax == 0.0) return 0.0; else if (ax > (double) n) { tox = 2.0 / ax; bjm = J0(ax); bj = J(ax); for (j = 1; j < n; j++) { bjp = j * tox * bj - bjm; bjm = bj; bj = bjp; } ans = bj; } else { tox = 2.0 / ax; m = 2 * ((n + (int) Math.sqrt(ACC * n)) / 2); jsum = false; bjp = ans = sum = 0.0; bj = 1.0; for (j = m; j > 0; j--) { bjm = j * tox * bj - bjp; bjp = bj; bj = bjm; if (Math.abs(bj) > BIGNO) { bj *= BIGNI; bjp *= BIGNI; ans *= BIGNI; sum *= BIGNI; } if (jsum) sum += bj; jsum = !jsum; if (j == n) ans = bjp; } sum = 2.0 * sum - bj; ans /= sum; } return x < 0.0 && n % 2 == 1 ? -ans : ans; }
java
public static double J(int n, double x) { int j, m; double ax, bj, bjm, bjp, sum, tox, ans; boolean jsum; double ACC = 40.0; double BIGNO = 1.0e+10; double BIGNI = 1.0e-10; if (n == 0) return J0(x); if (n == 1) return J(x); ax = Math.abs(x); if (ax == 0.0) return 0.0; else if (ax > (double) n) { tox = 2.0 / ax; bjm = J0(ax); bj = J(ax); for (j = 1; j < n; j++) { bjp = j * tox * bj - bjm; bjm = bj; bj = bjp; } ans = bj; } else { tox = 2.0 / ax; m = 2 * ((n + (int) Math.sqrt(ACC * n)) / 2); jsum = false; bjp = ans = sum = 0.0; bj = 1.0; for (j = m; j > 0; j--) { bjm = j * tox * bj - bjp; bjp = bj; bj = bjm; if (Math.abs(bj) > BIGNO) { bj *= BIGNI; bjp *= BIGNI; ans *= BIGNI; sum *= BIGNI; } if (jsum) sum += bj; jsum = !jsum; if (j == n) ans = bjp; } sum = 2.0 * sum - bj; ans /= sum; } return x < 0.0 && n % 2 == 1 ? -ans : ans; }
[ "public", "static", "double", "J", "(", "int", "n", ",", "double", "x", ")", "{", "int", "j", ",", "m", ";", "double", "ax", ",", "bj", ",", "bjm", ",", "bjp", ",", "sum", ",", "tox", ",", "ans", ";", "boolean", "jsum", ";", "double", "ACC", "=", "40.0", ";", "double", "BIGNO", "=", "1.0e+10", ";", "double", "BIGNI", "=", "1.0e-10", ";", "if", "(", "n", "==", "0", ")", "return", "J0", "(", "x", ")", ";", "if", "(", "n", "==", "1", ")", "return", "J", "(", "x", ")", ";", "ax", "=", "Math", ".", "abs", "(", "x", ")", ";", "if", "(", "ax", "==", "0.0", ")", "return", "0.0", ";", "else", "if", "(", "ax", ">", "(", "double", ")", "n", ")", "{", "tox", "=", "2.0", "/", "ax", ";", "bjm", "=", "J0", "(", "ax", ")", ";", "bj", "=", "J", "(", "ax", ")", ";", "for", "(", "j", "=", "1", ";", "j", "<", "n", ";", "j", "++", ")", "{", "bjp", "=", "j", "*", "tox", "*", "bj", "-", "bjm", ";", "bjm", "=", "bj", ";", "bj", "=", "bjp", ";", "}", "ans", "=", "bj", ";", "}", "else", "{", "tox", "=", "2.0", "/", "ax", ";", "m", "=", "2", "*", "(", "(", "n", "+", "(", "int", ")", "Math", ".", "sqrt", "(", "ACC", "*", "n", ")", ")", "/", "2", ")", ";", "jsum", "=", "false", ";", "bjp", "=", "ans", "=", "sum", "=", "0.0", ";", "bj", "=", "1.0", ";", "for", "(", "j", "=", "m", ";", "j", ">", "0", ";", "j", "--", ")", "{", "bjm", "=", "j", "*", "tox", "*", "bj", "-", "bjp", ";", "bjp", "=", "bj", ";", "bj", "=", "bjm", ";", "if", "(", "Math", ".", "abs", "(", "bj", ")", ">", "BIGNO", ")", "{", "bj", "*=", "BIGNI", ";", "bjp", "*=", "BIGNI", ";", "ans", "*=", "BIGNI", ";", "sum", "*=", "BIGNI", ";", "}", "if", "(", "jsum", ")", "sum", "+=", "bj", ";", "jsum", "=", "!", "jsum", ";", "if", "(", "j", "==", "n", ")", "ans", "=", "bjp", ";", "}", "sum", "=", "2.0", "*", "sum", "-", "bj", ";", "ans", "/=", "sum", ";", "}", "return", "x", "<", "0.0", "&&", "n", "%", "2", "==", "1", "?", "-", "ans", ":", "ans", ";", "}" ]
Bessel function of order n. @param n Order. @param x Value. @return J value.
[ "Bessel", "function", "of", "order", "n", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Bessel.java#L134-L183
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Bessel.java
Bessel.Y0
public static double Y0(double x) { if (x < 8.0) { double y = x * x; double ans1 = -2957821389.0 + y * (7062834065.0 + y * (-512359803.6 + y * (10879881.29 + y * (-86327.92757 + y * 228.4622733)))); double ans2 = 40076544269.0 + y * (745249964.8 + y * (7189466.438 + y * (47447.26470 + y * (226.1030244 + y * 1.0)))); return (ans1 / ans2) + 0.636619772 * J0(x) * Math.log(x); } else { double z = 8.0 / x; double y = z * z; double xx = x - 0.785398164; double ans1 = 1.0 + y * (-0.1098628627e-2 + y * (0.2734510407e-4 + y * (-0.2073370639e-5 + y * 0.2093887211e-6))); double ans2 = -0.1562499995e-1 + y * (0.1430488765e-3 + y * (-0.6911147651e-5 + y * (0.7621095161e-6 + y * (-0.934945152e-7)))); return Math.sqrt(0.636619772 / x) * (Math.sin(xx) * ans1 + z * Math.cos(xx) * ans2); } }
java
public static double Y0(double x) { if (x < 8.0) { double y = x * x; double ans1 = -2957821389.0 + y * (7062834065.0 + y * (-512359803.6 + y * (10879881.29 + y * (-86327.92757 + y * 228.4622733)))); double ans2 = 40076544269.0 + y * (745249964.8 + y * (7189466.438 + y * (47447.26470 + y * (226.1030244 + y * 1.0)))); return (ans1 / ans2) + 0.636619772 * J0(x) * Math.log(x); } else { double z = 8.0 / x; double y = z * z; double xx = x - 0.785398164; double ans1 = 1.0 + y * (-0.1098628627e-2 + y * (0.2734510407e-4 + y * (-0.2073370639e-5 + y * 0.2093887211e-6))); double ans2 = -0.1562499995e-1 + y * (0.1430488765e-3 + y * (-0.6911147651e-5 + y * (0.7621095161e-6 + y * (-0.934945152e-7)))); return Math.sqrt(0.636619772 / x) * (Math.sin(xx) * ans1 + z * Math.cos(xx) * ans2); } }
[ "public", "static", "double", "Y0", "(", "double", "x", ")", "{", "if", "(", "x", "<", "8.0", ")", "{", "double", "y", "=", "x", "*", "x", ";", "double", "ans1", "=", "-", "2957821389.0", "+", "y", "*", "(", "7062834065.0", "+", "y", "*", "(", "-", "512359803.6", "+", "y", "*", "(", "10879881.29", "+", "y", "*", "(", "-", "86327.92757", "+", "y", "*", "228.4622733", ")", ")", ")", ")", ";", "double", "ans2", "=", "40076544269.0", "+", "y", "*", "(", "745249964.8", "+", "y", "*", "(", "7189466.438", "+", "y", "*", "(", "47447.26470", "+", "y", "*", "(", "226.1030244", "+", "y", "*", "1.0", ")", ")", ")", ")", ";", "return", "(", "ans1", "/", "ans2", ")", "+", "0.636619772", "*", "J0", "(", "x", ")", "*", "Math", ".", "log", "(", "x", ")", ";", "}", "else", "{", "double", "z", "=", "8.0", "/", "x", ";", "double", "y", "=", "z", "*", "z", ";", "double", "xx", "=", "x", "-", "0.785398164", ";", "double", "ans1", "=", "1.0", "+", "y", "*", "(", "-", "0.1098628627e-2", "+", "y", "*", "(", "0.2734510407e-4", "+", "y", "*", "(", "-", "0.2073370639e-5", "+", "y", "*", "0.2093887211e-6", ")", ")", ")", ";", "double", "ans2", "=", "-", "0.1562499995e-1", "+", "y", "*", "(", "0.1430488765e-3", "+", "y", "*", "(", "-", "0.6911147651e-5", "+", "y", "*", "(", "0.7621095161e-6", "+", "y", "*", "(", "-", "0.934945152e-7", ")", ")", ")", ")", ";", "return", "Math", ".", "sqrt", "(", "0.636619772", "/", "x", ")", "*", "(", "Math", ".", "sin", "(", "xx", ")", "*", "ans1", "+", "z", "*", "Math", ".", "cos", "(", "xx", ")", "*", "ans2", ")", ";", "}", "}" ]
Bessel function of the second kind, of order 0. @param x Value. @return Y0 value.
[ "Bessel", "function", "of", "the", "second", "kind", "of", "order", "0", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Bessel.java#L191-L214
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Bessel.java
Bessel.Y
public static double Y(double x) { if (x < 8.0) { double y = x * x; double ans1 = x * (-0.4900604943e13 + y * (0.1275274390e13 + y * (-0.5153438139e11 + y * (0.7349264551e9 + y * (-0.4237922726e7 + y * 0.8511937935e4))))); double ans2 = 0.2499580570e14 + y * (0.4244419664e12 + y * (0.3733650367e10 + y * (0.2245904002e8 + y * (0.1020426050e6 + y * (0.3549632885e3 + y))))); return (ans1 / ans2) + 0.636619772 * (J(x) * Math.log(x) - 1.0 / x); } else { double z = 8.0 / x; double y = z * z; double xx = x - 2.356194491; double ans1 = 1.0 + y * (0.183105e-2 + y * (-0.3516396496e-4 + y * (0.2457520174e-5 + y * (-0.240337019e-6)))); double ans2 = 0.04687499995 + y * (-0.2002690873e-3 + y * (0.8449199096e-5 + y * (-0.88228987e-6 + y * 0.105787412e-6))); return Math.sqrt(0.636619772 / x) * (Math.sin(xx) * ans1 + z * Math.cos(xx) * ans2); } }
java
public static double Y(double x) { if (x < 8.0) { double y = x * x; double ans1 = x * (-0.4900604943e13 + y * (0.1275274390e13 + y * (-0.5153438139e11 + y * (0.7349264551e9 + y * (-0.4237922726e7 + y * 0.8511937935e4))))); double ans2 = 0.2499580570e14 + y * (0.4244419664e12 + y * (0.3733650367e10 + y * (0.2245904002e8 + y * (0.1020426050e6 + y * (0.3549632885e3 + y))))); return (ans1 / ans2) + 0.636619772 * (J(x) * Math.log(x) - 1.0 / x); } else { double z = 8.0 / x; double y = z * z; double xx = x - 2.356194491; double ans1 = 1.0 + y * (0.183105e-2 + y * (-0.3516396496e-4 + y * (0.2457520174e-5 + y * (-0.240337019e-6)))); double ans2 = 0.04687499995 + y * (-0.2002690873e-3 + y * (0.8449199096e-5 + y * (-0.88228987e-6 + y * 0.105787412e-6))); return Math.sqrt(0.636619772 / x) * (Math.sin(xx) * ans1 + z * Math.cos(xx) * ans2); } }
[ "public", "static", "double", "Y", "(", "double", "x", ")", "{", "if", "(", "x", "<", "8.0", ")", "{", "double", "y", "=", "x", "*", "x", ";", "double", "ans1", "=", "x", "*", "(", "-", "0.4900604943e13", "+", "y", "*", "(", "0.1275274390e13", "+", "y", "*", "(", "-", "0.5153438139e11", "+", "y", "*", "(", "0.7349264551e9", "+", "y", "*", "(", "-", "0.4237922726e7", "+", "y", "*", "0.8511937935e4", ")", ")", ")", ")", ")", ";", "double", "ans2", "=", "0.2499580570e14", "+", "y", "*", "(", "0.4244419664e12", "+", "y", "*", "(", "0.3733650367e10", "+", "y", "*", "(", "0.2245904002e8", "+", "y", "*", "(", "0.1020426050e6", "+", "y", "*", "(", "0.3549632885e3", "+", "y", ")", ")", ")", ")", ")", ";", "return", "(", "ans1", "/", "ans2", ")", "+", "0.636619772", "*", "(", "J", "(", "x", ")", "*", "Math", ".", "log", "(", "x", ")", "-", "1.0", "/", "x", ")", ";", "}", "else", "{", "double", "z", "=", "8.0", "/", "x", ";", "double", "y", "=", "z", "*", "z", ";", "double", "xx", "=", "x", "-", "2.356194491", ";", "double", "ans1", "=", "1.0", "+", "y", "*", "(", "0.183105e-2", "+", "y", "*", "(", "-", "0.3516396496e-4", "+", "y", "*", "(", "0.2457520174e-5", "+", "y", "*", "(", "-", "0.240337019e-6", ")", ")", ")", ")", ";", "double", "ans2", "=", "0.04687499995", "+", "y", "*", "(", "-", "0.2002690873e-3", "+", "y", "*", "(", "0.8449199096e-5", "+", "y", "*", "(", "-", "0.88228987e-6", "+", "y", "*", "0.105787412e-6", ")", ")", ")", ";", "return", "Math", ".", "sqrt", "(", "0.636619772", "/", "x", ")", "*", "(", "Math", ".", "sin", "(", "xx", ")", "*", "ans1", "+", "z", "*", "Math", ".", "cos", "(", "xx", ")", "*", "ans2", ")", ";", "}", "}" ]
Bessel function of the second kind, of order 1. @param x Value. @return Y value.
[ "Bessel", "function", "of", "the", "second", "kind", "of", "order", "1", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Bessel.java#L222-L244
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Bessel.java
Bessel.Y
public static double Y(int n, double x) { double by, bym, byp, tox; if (n == 0) return Y0(x); if (n == 1) return Y(x); tox = 2.0 / x; by = Y(x); bym = Y0(x); for (int j = 1; j < n; j++) { byp = j * tox * by - bym; bym = by; by = byp; } return by; }
java
public static double Y(int n, double x) { double by, bym, byp, tox; if (n == 0) return Y0(x); if (n == 1) return Y(x); tox = 2.0 / x; by = Y(x); bym = Y0(x); for (int j = 1; j < n; j++) { byp = j * tox * by - bym; bym = by; by = byp; } return by; }
[ "public", "static", "double", "Y", "(", "int", "n", ",", "double", "x", ")", "{", "double", "by", ",", "bym", ",", "byp", ",", "tox", ";", "if", "(", "n", "==", "0", ")", "return", "Y0", "(", "x", ")", ";", "if", "(", "n", "==", "1", ")", "return", "Y", "(", "x", ")", ";", "tox", "=", "2.0", "/", "x", ";", "by", "=", "Y", "(", "x", ")", ";", "bym", "=", "Y0", "(", "x", ")", ";", "for", "(", "int", "j", "=", "1", ";", "j", "<", "n", ";", "j", "++", ")", "{", "byp", "=", "j", "*", "tox", "*", "by", "-", "bym", ";", "bym", "=", "by", ";", "by", "=", "byp", ";", "}", "return", "by", ";", "}" ]
Bessel function of the second kind, of order n. @param n Order. @param x Value. @return Y value.
[ "Bessel", "function", "of", "the", "second", "kind", "of", "order", "n", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Bessel.java#L253-L268
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Bessel.java
Bessel.I0
public static double I0(double x) { double ans; double ax = Math.abs(x); if (ax < 3.75) { double y = x / 3.75; y = y * y; ans = 1.0 + y * (3.5156229 + y * (3.0899424 + y * (1.2067492 + y * (0.2659732 + y * (0.360768e-1 + y * 0.45813e-2))))); } else { double y = 3.75 / ax; ans = (Math.exp(ax) / Math.sqrt(ax)) * (0.39894228 + y * (0.1328592e-1 + y * (0.225319e-2 + y * (-0.157565e-2 + y * (0.916281e-2 + y * (-0.2057706e-1 + y * (0.2635537e-1 + y * (-0.1647633e-1 + y * 0.392377e-2)))))))); } return ans; }
java
public static double I0(double x) { double ans; double ax = Math.abs(x); if (ax < 3.75) { double y = x / 3.75; y = y * y; ans = 1.0 + y * (3.5156229 + y * (3.0899424 + y * (1.2067492 + y * (0.2659732 + y * (0.360768e-1 + y * 0.45813e-2))))); } else { double y = 3.75 / ax; ans = (Math.exp(ax) / Math.sqrt(ax)) * (0.39894228 + y * (0.1328592e-1 + y * (0.225319e-2 + y * (-0.157565e-2 + y * (0.916281e-2 + y * (-0.2057706e-1 + y * (0.2635537e-1 + y * (-0.1647633e-1 + y * 0.392377e-2)))))))); } return ans; }
[ "public", "static", "double", "I0", "(", "double", "x", ")", "{", "double", "ans", ";", "double", "ax", "=", "Math", ".", "abs", "(", "x", ")", ";", "if", "(", "ax", "<", "3.75", ")", "{", "double", "y", "=", "x", "/", "3.75", ";", "y", "=", "y", "*", "y", ";", "ans", "=", "1.0", "+", "y", "*", "(", "3.5156229", "+", "y", "*", "(", "3.0899424", "+", "y", "*", "(", "1.2067492", "+", "y", "*", "(", "0.2659732", "+", "y", "*", "(", "0.360768e-1", "+", "y", "*", "0.45813e-2", ")", ")", ")", ")", ")", ";", "}", "else", "{", "double", "y", "=", "3.75", "/", "ax", ";", "ans", "=", "(", "Math", ".", "exp", "(", "ax", ")", "/", "Math", ".", "sqrt", "(", "ax", ")", ")", "*", "(", "0.39894228", "+", "y", "*", "(", "0.1328592e-1", "+", "y", "*", "(", "0.225319e-2", "+", "y", "*", "(", "-", "0.157565e-2", "+", "y", "*", "(", "0.916281e-2", "+", "y", "*", "(", "-", "0.2057706e-1", "+", "y", "*", "(", "0.2635537e-1", "+", "y", "*", "(", "-", "0.1647633e-1", "+", "y", "*", "0.392377e-2", ")", ")", ")", ")", ")", ")", ")", ")", ";", "}", "return", "ans", ";", "}" ]
Bessel function of the first kind, of order 0. @param x Value. @return I0 value.
[ "Bessel", "function", "of", "the", "first", "kind", "of", "order", "0", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Bessel.java#L276-L294
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Bessel.java
Bessel.I
public static double I(int n, double x) { if (n < 0) throw new IllegalArgumentException("the variable n out of range."); else if (n == 0) return I0(x); else if (n == 1) return I(x); if (x == 0.0) return 0.0; double ACC = 40.0; double BIGNO = 1.0e+10; double BIGNI = 1.0e-10; double tox = 2.0 / Math.abs(x); double bip = 0, ans = 0.0; double bi = 1.0; for (int j = 2 * (n + (int) Math.sqrt(ACC * n)); j > 0; j--) { double bim = bip + j * tox * bi; bip = bi; bi = bim; if (Math.abs(bi) > BIGNO) { ans *= BIGNI; bi *= BIGNI; bip *= BIGNI; } if (j == n) ans = bip; } ans *= I0(x) / bi; return x < 0.0 && n % 2 == 1 ? -ans : ans; }
java
public static double I(int n, double x) { if (n < 0) throw new IllegalArgumentException("the variable n out of range."); else if (n == 0) return I0(x); else if (n == 1) return I(x); if (x == 0.0) return 0.0; double ACC = 40.0; double BIGNO = 1.0e+10; double BIGNI = 1.0e-10; double tox = 2.0 / Math.abs(x); double bip = 0, ans = 0.0; double bi = 1.0; for (int j = 2 * (n + (int) Math.sqrt(ACC * n)); j > 0; j--) { double bim = bip + j * tox * bi; bip = bi; bi = bim; if (Math.abs(bi) > BIGNO) { ans *= BIGNI; bi *= BIGNI; bip *= BIGNI; } if (j == n) ans = bip; } ans *= I0(x) / bi; return x < 0.0 && n % 2 == 1 ? -ans : ans; }
[ "public", "static", "double", "I", "(", "int", "n", ",", "double", "x", ")", "{", "if", "(", "n", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"the variable n out of range.\"", ")", ";", "else", "if", "(", "n", "==", "0", ")", "return", "I0", "(", "x", ")", ";", "else", "if", "(", "n", "==", "1", ")", "return", "I", "(", "x", ")", ";", "if", "(", "x", "==", "0.0", ")", "return", "0.0", ";", "double", "ACC", "=", "40.0", ";", "double", "BIGNO", "=", "1.0e+10", ";", "double", "BIGNI", "=", "1.0e-10", ";", "double", "tox", "=", "2.0", "/", "Math", ".", "abs", "(", "x", ")", ";", "double", "bip", "=", "0", ",", "ans", "=", "0.0", ";", "double", "bi", "=", "1.0", ";", "for", "(", "int", "j", "=", "2", "*", "(", "n", "+", "(", "int", ")", "Math", ".", "sqrt", "(", "ACC", "*", "n", ")", ")", ";", "j", ">", "0", ";", "j", "--", ")", "{", "double", "bim", "=", "bip", "+", "j", "*", "tox", "*", "bi", ";", "bip", "=", "bi", ";", "bi", "=", "bim", ";", "if", "(", "Math", ".", "abs", "(", "bi", ")", ">", "BIGNO", ")", "{", "ans", "*=", "BIGNI", ";", "bi", "*=", "BIGNI", ";", "bip", "*=", "BIGNI", ";", "}", "if", "(", "j", "==", "n", ")", "ans", "=", "bip", ";", "}", "ans", "*=", "I0", "(", "x", ")", "/", "bi", ";", "return", "x", "<", "0.0", "&&", "n", "%", "2", "==", "1", "?", "-", "ans", ":", "ans", ";", "}" ]
Bessel function of the first kind, of order n. @param n Order. @param x Value. @return I value.
[ "Bessel", "function", "of", "the", "first", "kind", "of", "order", "n", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Bessel.java#L328-L364
train
Harium/keel
src/main/java/com/harium/keel/effect/normal/SobelNormalMap.java
SobelNormalMap.apply
@Override public ImageSource apply(ImageSource input) { int w = input.getWidth(); int h = input.getHeight(); MatrixSource output = new MatrixSource(input); Vector3 n = new Vector3(0, 0, 1); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { if (x < border || x == w - border || y < border || y == h - border) { output.setRGB(x, y, VectorHelper.Z_NORMAL); continue; } float s0 = input.getR(x - 1, y + 1); float s1 = input.getR(x, y + 1); float s2 = input.getR(x + 1, y + 1); float s3 = input.getR(x - 1, y); float s5 = input.getR(x + 1, y); float s6 = input.getR(x - 1, y - 1); float s7 = input.getR(x, y - 1); float s8 = input.getR(x + 1, y - 1); float nx = -(s2 - s0 + 2 * (s5 - s3) + s8 - s6); float ny = -(s6 - s0 + 2 * (s7 - s1) + s8 - s2); n.set(nx, ny, scale); n.nor(); int rgb = VectorHelper.vectorToColor(n); output.setRGB(x, y, rgb); } } return new MatrixSource(output); }
java
@Override public ImageSource apply(ImageSource input) { int w = input.getWidth(); int h = input.getHeight(); MatrixSource output = new MatrixSource(input); Vector3 n = new Vector3(0, 0, 1); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { if (x < border || x == w - border || y < border || y == h - border) { output.setRGB(x, y, VectorHelper.Z_NORMAL); continue; } float s0 = input.getR(x - 1, y + 1); float s1 = input.getR(x, y + 1); float s2 = input.getR(x + 1, y + 1); float s3 = input.getR(x - 1, y); float s5 = input.getR(x + 1, y); float s6 = input.getR(x - 1, y - 1); float s7 = input.getR(x, y - 1); float s8 = input.getR(x + 1, y - 1); float nx = -(s2 - s0 + 2 * (s5 - s3) + s8 - s6); float ny = -(s6 - s0 + 2 * (s7 - s1) + s8 - s2); n.set(nx, ny, scale); n.nor(); int rgb = VectorHelper.vectorToColor(n); output.setRGB(x, y, rgb); } } return new MatrixSource(output); }
[ "@", "Override", "public", "ImageSource", "apply", "(", "ImageSource", "input", ")", "{", "int", "w", "=", "input", ".", "getWidth", "(", ")", ";", "int", "h", "=", "input", ".", "getHeight", "(", ")", ";", "MatrixSource", "output", "=", "new", "MatrixSource", "(", "input", ")", ";", "Vector3", "n", "=", "new", "Vector3", "(", "0", ",", "0", ",", "1", ")", ";", "for", "(", "int", "y", "=", "0", ";", "y", "<", "h", ";", "y", "++", ")", "{", "for", "(", "int", "x", "=", "0", ";", "x", "<", "w", ";", "x", "++", ")", "{", "if", "(", "x", "<", "border", "||", "x", "==", "w", "-", "border", "||", "y", "<", "border", "||", "y", "==", "h", "-", "border", ")", "{", "output", ".", "setRGB", "(", "x", ",", "y", ",", "VectorHelper", ".", "Z_NORMAL", ")", ";", "continue", ";", "}", "float", "s0", "=", "input", ".", "getR", "(", "x", "-", "1", ",", "y", "+", "1", ")", ";", "float", "s1", "=", "input", ".", "getR", "(", "x", ",", "y", "+", "1", ")", ";", "float", "s2", "=", "input", ".", "getR", "(", "x", "+", "1", ",", "y", "+", "1", ")", ";", "float", "s3", "=", "input", ".", "getR", "(", "x", "-", "1", ",", "y", ")", ";", "float", "s5", "=", "input", ".", "getR", "(", "x", "+", "1", ",", "y", ")", ";", "float", "s6", "=", "input", ".", "getR", "(", "x", "-", "1", ",", "y", "-", "1", ")", ";", "float", "s7", "=", "input", ".", "getR", "(", "x", ",", "y", "-", "1", ")", ";", "float", "s8", "=", "input", ".", "getR", "(", "x", "+", "1", ",", "y", "-", "1", ")", ";", "float", "nx", "=", "-", "(", "s2", "-", "s0", "+", "2", "*", "(", "s5", "-", "s3", ")", "+", "s8", "-", "s6", ")", ";", "float", "ny", "=", "-", "(", "s6", "-", "s0", "+", "2", "*", "(", "s7", "-", "s1", ")", "+", "s8", "-", "s2", ")", ";", "n", ".", "set", "(", "nx", ",", "ny", ",", "scale", ")", ";", "n", ".", "nor", "(", ")", ";", "int", "rgb", "=", "VectorHelper", ".", "vectorToColor", "(", "n", ")", ";", "output", ".", "setRGB", "(", "x", ",", "y", ",", "rgb", ")", ";", "}", "}", "return", "new", "MatrixSource", "(", "output", ")", ";", "}" ]
Sobel method to generate bump map from a height map @param input - A height map @return bump map
[ "Sobel", "method", "to", "generate", "bump", "map", "from", "a", "height", "map" ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/effect/normal/SobelNormalMap.java#L19-L57
train
hyleung/ratpack-zipkin
src/main/java/ratpack/zipkin/internal/RatpackCurrentTraceContext.java
RatpackCurrentTraceContext.wrap
@Deprecated public static TraceContextHolder wrap(TraceContext traceContext) { return (traceContext != null) ? new TraceContextHolder(traceContext) : TraceContextHolder.EMPTY; }
java
@Deprecated public static TraceContextHolder wrap(TraceContext traceContext) { return (traceContext != null) ? new TraceContextHolder(traceContext) : TraceContextHolder.EMPTY; }
[ "@", "Deprecated", "public", "static", "TraceContextHolder", "wrap", "(", "TraceContext", "traceContext", ")", "{", "return", "(", "traceContext", "!=", "null", ")", "?", "new", "TraceContextHolder", "(", "traceContext", ")", ":", "TraceContextHolder", ".", "EMPTY", ";", "}" ]
Used by TracedParallelBatch where its used to wrap a TraceContext and puts it in the registry for the forked execution. This is marked deprecated as we prefer not to expose details of the RatpackCurrentTraceContext implementation. @param traceContext a trace context. @return a holder for the trace context, which can be put into the registry.
[ "Used", "by", "TracedParallelBatch", "where", "its", "used", "to", "wrap", "a", "TraceContext", "and", "puts", "it", "in", "the", "registry", "for", "the", "forked", "execution", ".", "This", "is", "marked", "deprecated", "as", "we", "prefer", "not", "to", "expose", "details", "of", "the", "RatpackCurrentTraceContext", "implementation", "." ]
3c9e4b05e3f5fab034c1f7832fffce8a55c311d3
https://github.com/hyleung/ratpack-zipkin/blob/3c9e4b05e3f5fab034c1f7832fffce8a55c311d3/src/main/java/ratpack/zipkin/internal/RatpackCurrentTraceContext.java#L64-L67
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/Tools.java
Tools.Sinc
public static double Sinc(double x) { return Math.sin(Math.PI * x) / (Math.PI * x); }
java
public static double Sinc(double x) { return Math.sin(Math.PI * x) / (Math.PI * x); }
[ "public", "static", "double", "Sinc", "(", "double", "x", ")", "{", "return", "Math", ".", "sin", "(", "Math", ".", "PI", "*", "x", ")", "/", "(", "Math", ".", "PI", "*", "x", ")", ";", "}" ]
Sinc function. @param x Value. @return Sinc of the value.
[ "Sinc", "function", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/Tools.java#L68-L70
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/Tools.java
Tools.Mod
public static int Mod(int x, int m) { if (m < 0) m = -m; int r = x % m; return r < 0 ? r + m : r; }
java
public static int Mod(int x, int m) { if (m < 0) m = -m; int r = x % m; return r < 0 ? r + m : r; }
[ "public", "static", "int", "Mod", "(", "int", "x", ",", "int", "m", ")", "{", "if", "(", "m", "<", "0", ")", "m", "=", "-", "m", ";", "int", "r", "=", "x", "%", "m", ";", "return", "r", "<", "0", "?", "r", "+", "m", ":", "r", ";", "}" ]
Gets the proper modulus operation. @param x Integer. @param m Modulo. @return Modulus.
[ "Gets", "the", "proper", "modulus", "operation", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/Tools.java#L349-L353
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/Tools.java
Tools.NextPowerOf2
public static int NextPowerOf2(int x) { --x; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; return ++x; }
java
public static int NextPowerOf2(int x) { --x; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; return ++x; }
[ "public", "static", "int", "NextPowerOf2", "(", "int", "x", ")", "{", "--", "x", ";", "x", "|=", "x", ">>", "1", ";", "x", "|=", "x", ">>", "2", ";", "x", "|=", "x", ">>", "4", ";", "x", "|=", "x", ">>", "8", ";", "x", "|=", "x", ">>", "16", ";", "return", "++", "x", ";", "}" ]
Returns the next power of 2 after the input value x. @param x Input value x. @return Returns the next power of 2 after the input value x.
[ "Returns", "the", "next", "power", "of", "2", "after", "the", "input", "value", "x", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/Tools.java#L361-L369
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/Tools.java
Tools.Sum
public static float Sum(float[] data) { float sum = 0; for (int i = 0; i < data.length; i++) { sum += data[i]; } return sum; }
java
public static float Sum(float[] data) { float sum = 0; for (int i = 0; i < data.length; i++) { sum += data[i]; } return sum; }
[ "public", "static", "float", "Sum", "(", "float", "[", "]", "data", ")", "{", "float", "sum", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "sum", "+=", "data", "[", "i", "]", ";", "}", "return", "sum", ";", "}" ]
Sum of the elements. @param data Data. @return Sum(data).
[ "Sum", "of", "the", "elements", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/Tools.java#L502-L508
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/Tools.java
Tools.TruncatedPower
public static double TruncatedPower(double value, double degree) { double x = Math.pow(value, degree); return (x > 0) ? x : 0.0; }
java
public static double TruncatedPower(double value, double degree) { double x = Math.pow(value, degree); return (x > 0) ? x : 0.0; }
[ "public", "static", "double", "TruncatedPower", "(", "double", "value", ",", "double", "degree", ")", "{", "double", "x", "=", "Math", ".", "pow", "(", "value", ",", "degree", ")", ";", "return", "(", "x", ">", "0", ")", "?", "x", ":", "0.0", ";", "}" ]
Truncated power function. @param value Value. @param degree Degree. @return Result.
[ "Truncated", "power", "function", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/Tools.java#L528-L531
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/Tools.java
Tools.Unique
public static int[] Unique(int[] values) { HashSet<Integer> lst = new HashSet<Integer>(); for (int i = 0; i < values.length; i++) { lst.add(values[i]); } int[] v = new int[lst.size()]; Iterator<Integer> it = lst.iterator(); for (int i = 0; i < v.length; i++) { v[i] = it.next(); } return v; }
java
public static int[] Unique(int[] values) { HashSet<Integer> lst = new HashSet<Integer>(); for (int i = 0; i < values.length; i++) { lst.add(values[i]); } int[] v = new int[lst.size()]; Iterator<Integer> it = lst.iterator(); for (int i = 0; i < v.length; i++) { v[i] = it.next(); } return v; }
[ "public", "static", "int", "[", "]", "Unique", "(", "int", "[", "]", "values", ")", "{", "HashSet", "<", "Integer", ">", "lst", "=", "new", "HashSet", "<", "Integer", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "values", ".", "length", ";", "i", "++", ")", "{", "lst", ".", "add", "(", "values", "[", "i", "]", ")", ";", "}", "int", "[", "]", "v", "=", "new", "int", "[", "lst", ".", "size", "(", ")", "]", ";", "Iterator", "<", "Integer", ">", "it", "=", "lst", ".", "iterator", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "v", ".", "length", ";", "i", "++", ")", "{", "v", "[", "i", "]", "=", "it", ".", "next", "(", ")", ";", "}", "return", "v", ";", "}" ]
Get unique values form the array. @param values Array of values. @return Unique values.
[ "Get", "unique", "values", "form", "the", "array", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/Tools.java#L539-L552
train
Harium/keel
src/main/java/com/harium/keel/effect/AlphaTrimmedMean.java
AlphaTrimmedMean.setT
public void setT(int t) { this.t = Math.min((radius * 2 + 1) * (radius * 2 + 1) / 2, Math.max(0, t)); }
java
public void setT(int t) { this.t = Math.min((radius * 2 + 1) * (radius * 2 + 1) / 2, Math.max(0, t)); }
[ "public", "void", "setT", "(", "int", "t", ")", "{", "this", ".", "t", "=", "Math", ".", "min", "(", "(", "radius", "*", "2", "+", "1", ")", "*", "(", "radius", "*", "2", "+", "1", ")", "/", "2", ",", "Math", ".", "max", "(", "0", ",", "t", ")", ")", ";", "}" ]
Set trimmed value. @param t Trimmed value.
[ "Set", "trimmed", "value", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/effect/AlphaTrimmedMean.java#L60-L62
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/TaylorSeries.java
TaylorSeries.Sin
public static double Sin(double x, int nTerms) { if (nTerms < 2) return x; if (nTerms == 2) { return x - (x * x * x) / 6D; } else { double mult = x * x * x; double fact = 6; double sign = 1; int factS = 5; double result = x - mult / fact; for (int i = 3; i <= nTerms; i++) { mult *= x * x; fact *= factS * (factS - 1); factS += 2; result += sign * (mult / fact); sign *= -1; } return result; } }
java
public static double Sin(double x, int nTerms) { if (nTerms < 2) return x; if (nTerms == 2) { return x - (x * x * x) / 6D; } else { double mult = x * x * x; double fact = 6; double sign = 1; int factS = 5; double result = x - mult / fact; for (int i = 3; i <= nTerms; i++) { mult *= x * x; fact *= factS * (factS - 1); factS += 2; result += sign * (mult / fact); sign *= -1; } return result; } }
[ "public", "static", "double", "Sin", "(", "double", "x", ",", "int", "nTerms", ")", "{", "if", "(", "nTerms", "<", "2", ")", "return", "x", ";", "if", "(", "nTerms", "==", "2", ")", "{", "return", "x", "-", "(", "x", "*", "x", "*", "x", ")", "/", "6D", ";", "}", "else", "{", "double", "mult", "=", "x", "*", "x", "*", "x", ";", "double", "fact", "=", "6", ";", "double", "sign", "=", "1", ";", "int", "factS", "=", "5", ";", "double", "result", "=", "x", "-", "mult", "/", "fact", ";", "for", "(", "int", "i", "=", "3", ";", "i", "<=", "nTerms", ";", "i", "++", ")", "{", "mult", "*=", "x", "*", "x", ";", "fact", "*=", "factS", "*", "(", "factS", "-", "1", ")", ";", "factS", "+=", "2", ";", "result", "+=", "sign", "*", "(", "mult", "/", "fact", ")", ";", "sign", "*=", "-", "1", ";", "}", "return", "result", ";", "}", "}" ]
compute Sin using Taylor Series. @param x An angle, in radians. @param nTerms Number of terms. @return Result.
[ "compute", "Sin", "using", "Taylor", "Series", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/TaylorSeries.java#L47-L68
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/TaylorSeries.java
TaylorSeries.Sinh
public static double Sinh(double x, int nTerms) { if (nTerms < 2) return x; if (nTerms == 2) { return x + (x * x * x) / 6D; } else { double mult = x * x * x; double fact = 6; int factS = 5; double result = x + mult / fact; for (int i = 3; i <= nTerms; i++) { mult *= x * x; fact *= factS * (factS - 1); factS += 2; result += mult / fact; } return result; } }
java
public static double Sinh(double x, int nTerms) { if (nTerms < 2) return x; if (nTerms == 2) { return x + (x * x * x) / 6D; } else { double mult = x * x * x; double fact = 6; int factS = 5; double result = x + mult / fact; for (int i = 3; i <= nTerms; i++) { mult *= x * x; fact *= factS * (factS - 1); factS += 2; result += mult / fact; } return result; } }
[ "public", "static", "double", "Sinh", "(", "double", "x", ",", "int", "nTerms", ")", "{", "if", "(", "nTerms", "<", "2", ")", "return", "x", ";", "if", "(", "nTerms", "==", "2", ")", "{", "return", "x", "+", "(", "x", "*", "x", "*", "x", ")", "/", "6D", ";", "}", "else", "{", "double", "mult", "=", "x", "*", "x", "*", "x", ";", "double", "fact", "=", "6", ";", "int", "factS", "=", "5", ";", "double", "result", "=", "x", "+", "mult", "/", "fact", ";", "for", "(", "int", "i", "=", "3", ";", "i", "<=", "nTerms", ";", "i", "++", ")", "{", "mult", "*=", "x", "*", "x", ";", "fact", "*=", "factS", "*", "(", "factS", "-", "1", ")", ";", "factS", "+=", "2", ";", "result", "+=", "mult", "/", "fact", ";", "}", "return", "result", ";", "}", "}" ]
compute Sinh using Taylor Series. @param x An angle, in radians. @param nTerms Number of terms. @return Result.
[ "compute", "Sinh", "using", "Taylor", "Series", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/TaylorSeries.java#L107-L126
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/TaylorSeries.java
TaylorSeries.Cosh
public static double Cosh(double x, int nTerms) { if (nTerms < 2) return x; if (nTerms == 2) { return 1 + (x * x) / 2D; } else { double mult = x * x; double fact = 2; int factS = 4; double result = 1 + mult / fact; for (int i = 3; i <= nTerms; i++) { mult *= x * x; fact *= factS * (factS - 1); factS += 2; result += mult / fact; } return result; } }
java
public static double Cosh(double x, int nTerms) { if (nTerms < 2) return x; if (nTerms == 2) { return 1 + (x * x) / 2D; } else { double mult = x * x; double fact = 2; int factS = 4; double result = 1 + mult / fact; for (int i = 3; i <= nTerms; i++) { mult *= x * x; fact *= factS * (factS - 1); factS += 2; result += mult / fact; } return result; } }
[ "public", "static", "double", "Cosh", "(", "double", "x", ",", "int", "nTerms", ")", "{", "if", "(", "nTerms", "<", "2", ")", "return", "x", ";", "if", "(", "nTerms", "==", "2", ")", "{", "return", "1", "+", "(", "x", "*", "x", ")", "/", "2D", ";", "}", "else", "{", "double", "mult", "=", "x", "*", "x", ";", "double", "fact", "=", "2", ";", "int", "factS", "=", "4", ";", "double", "result", "=", "1", "+", "mult", "/", "fact", ";", "for", "(", "int", "i", "=", "3", ";", "i", "<=", "nTerms", ";", "i", "++", ")", "{", "mult", "*=", "x", "*", "x", ";", "fact", "*=", "factS", "*", "(", "factS", "-", "1", ")", ";", "factS", "+=", "2", ";", "result", "+=", "mult", "/", "fact", ";", "}", "return", "result", ";", "}", "}" ]
compute Cosh using Taylor Series. @param x An angle, in radians. @param nTerms Number of terms. @return Result.
[ "compute", "Cosh", "using", "Taylor", "Series", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/TaylorSeries.java#L135-L154
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/TaylorSeries.java
TaylorSeries.Exp
public static double Exp(double x, int nTerms) { if (nTerms < 2) return 1 + x; if (nTerms == 2) { return 1 + x + (x * x) / 2; } else { double mult = x * x; double fact = 2; double result = 1 + x + mult / fact; for (int i = 3; i <= nTerms; i++) { mult *= x; fact *= i; result += mult / fact; } return result; } }
java
public static double Exp(double x, int nTerms) { if (nTerms < 2) return 1 + x; if (nTerms == 2) { return 1 + x + (x * x) / 2; } else { double mult = x * x; double fact = 2; double result = 1 + x + mult / fact; for (int i = 3; i <= nTerms; i++) { mult *= x; fact *= i; result += mult / fact; } return result; } }
[ "public", "static", "double", "Exp", "(", "double", "x", ",", "int", "nTerms", ")", "{", "if", "(", "nTerms", "<", "2", ")", "return", "1", "+", "x", ";", "if", "(", "nTerms", "==", "2", ")", "{", "return", "1", "+", "x", "+", "(", "x", "*", "x", ")", "/", "2", ";", "}", "else", "{", "double", "mult", "=", "x", "*", "x", ";", "double", "fact", "=", "2", ";", "double", "result", "=", "1", "+", "x", "+", "mult", "/", "fact", ";", "for", "(", "int", "i", "=", "3", ";", "i", "<=", "nTerms", ";", "i", "++", ")", "{", "mult", "*=", "x", ";", "fact", "*=", "i", ";", "result", "+=", "mult", "/", "fact", ";", "}", "return", "result", ";", "}", "}" ]
compute Exp using Taylor Series. @param x An angle, in radians. @param nTerms Number of terms. @return Result.
[ "compute", "Exp", "using", "Taylor", "Series", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/TaylorSeries.java#L163-L180
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/decomposition/LUDecomposition.java
LUDecomposition.getU
public double[][] getU() { double[][] X = new double[n][n]; double[][] U = X; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i <= j) { U[i][j] = LU[i][j]; } else { U[i][j] = 0.0; } } } return X; }
java
public double[][] getU() { double[][] X = new double[n][n]; double[][] U = X; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i <= j) { U[i][j] = LU[i][j]; } else { U[i][j] = 0.0; } } } return X; }
[ "public", "double", "[", "]", "[", "]", "getU", "(", ")", "{", "double", "[", "]", "[", "]", "X", "=", "new", "double", "[", "n", "]", "[", "n", "]", ";", "double", "[", "]", "[", "]", "U", "=", "X", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "n", ";", "j", "++", ")", "{", "if", "(", "i", "<=", "j", ")", "{", "U", "[", "i", "]", "[", "j", "]", "=", "LU", "[", "i", "]", "[", "j", "]", ";", "}", "else", "{", "U", "[", "i", "]", "[", "j", "]", "=", "0.0", ";", "}", "}", "}", "return", "X", ";", "}" ]
Get the Upper triangular factor. @return U.
[ "Get", "the", "Upper", "triangular", "factor", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/decomposition/LUDecomposition.java#L194-L207
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/decomposition/LUDecomposition.java
LUDecomposition.determinant
public double determinant() { if (m != n) { throw new IllegalArgumentException("Matrix must be square."); } double d = (double) pivsign; for (int j = 0; j < n; j++) { d *= LU[j][j]; } return d; }
java
public double determinant() { if (m != n) { throw new IllegalArgumentException("Matrix must be square."); } double d = (double) pivsign; for (int j = 0; j < n; j++) { d *= LU[j][j]; } return d; }
[ "public", "double", "determinant", "(", ")", "{", "if", "(", "m", "!=", "n", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Matrix must be square.\"", ")", ";", "}", "double", "d", "=", "(", "double", ")", "pivsign", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "n", ";", "j", "++", ")", "{", "d", "*=", "LU", "[", "j", "]", "[", "j", "]", ";", "}", "return", "d", ";", "}" ]
Calculate the determinant. @return Determinant.
[ "Calculate", "the", "determinant", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/decomposition/LUDecomposition.java#L244-L253
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Add
public static ComplexNumber Add(ComplexNumber z1, ComplexNumber z2) { return new ComplexNumber(z1.real + z2.real, z1.imaginary + z2.imaginary); }
java
public static ComplexNumber Add(ComplexNumber z1, ComplexNumber z2) { return new ComplexNumber(z1.real + z2.real, z1.imaginary + z2.imaginary); }
[ "public", "static", "ComplexNumber", "Add", "(", "ComplexNumber", "z1", ",", "ComplexNumber", "z2", ")", "{", "return", "new", "ComplexNumber", "(", "z1", ".", "real", "+", "z2", ".", "real", ",", "z1", ".", "imaginary", "+", "z2", ".", "imaginary", ")", ";", "}" ]
Adds two complex numbers. @param z1 Complex Number. @param z2 Complex Number. @return Returns new ComplexNumber instance containing the sum of specified complex numbers.
[ "Adds", "two", "complex", "numbers", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L241-L243
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Add
public static ComplexNumber Add(ComplexNumber z1, double scalar) { return new ComplexNumber(z1.real + scalar, z1.imaginary); }
java
public static ComplexNumber Add(ComplexNumber z1, double scalar) { return new ComplexNumber(z1.real + scalar, z1.imaginary); }
[ "public", "static", "ComplexNumber", "Add", "(", "ComplexNumber", "z1", ",", "double", "scalar", ")", "{", "return", "new", "ComplexNumber", "(", "z1", ".", "real", "+", "scalar", ",", "z1", ".", "imaginary", ")", ";", "}" ]
Adds the complex number with a scalar value. @param z1 Complex Number. @param scalar Scalar value. @return Returns new ComplexNumber instance containing the add of specified complex number with scalar value.
[ "Adds", "the", "complex", "number", "with", "a", "scalar", "value", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L252-L254
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Subtract
public static ComplexNumber Subtract(ComplexNumber z1, ComplexNumber z2) { return new ComplexNumber(z1.real - z2.real, z1.imaginary - z2.imaginary); }
java
public static ComplexNumber Subtract(ComplexNumber z1, ComplexNumber z2) { return new ComplexNumber(z1.real - z2.real, z1.imaginary - z2.imaginary); }
[ "public", "static", "ComplexNumber", "Subtract", "(", "ComplexNumber", "z1", ",", "ComplexNumber", "z2", ")", "{", "return", "new", "ComplexNumber", "(", "z1", ".", "real", "-", "z2", ".", "real", ",", "z1", ".", "imaginary", "-", "z2", ".", "imaginary", ")", ";", "}" ]
Subtract two complex numbers. @param z1 Complex Number. @param z2 Complex Number. @return Returns new ComplexNumber instance containing the subtract of specified complex numbers.
[ "Subtract", "two", "complex", "numbers", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L272-L274
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Subtract
public static ComplexNumber Subtract(ComplexNumber z1, double scalar) { return new ComplexNumber(z1.real - scalar, z1.imaginary); }
java
public static ComplexNumber Subtract(ComplexNumber z1, double scalar) { return new ComplexNumber(z1.real - scalar, z1.imaginary); }
[ "public", "static", "ComplexNumber", "Subtract", "(", "ComplexNumber", "z1", ",", "double", "scalar", ")", "{", "return", "new", "ComplexNumber", "(", "z1", ".", "real", "-", "scalar", ",", "z1", ".", "imaginary", ")", ";", "}" ]
Subtract a complex number. @param z1 Complex Number. @param scalar Scalar value. @return Returns new ComplexNumber instance containing the subtract of specified complex number with a scalar value.
[ "Subtract", "a", "complex", "number", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L283-L285
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Magnitude
public static double Magnitude(ComplexNumber z) { return Math.sqrt(z.real * z.real + z.imaginary * z.imaginary); }
java
public static double Magnitude(ComplexNumber z) { return Math.sqrt(z.real * z.real + z.imaginary * z.imaginary); }
[ "public", "static", "double", "Magnitude", "(", "ComplexNumber", "z", ")", "{", "return", "Math", ".", "sqrt", "(", "z", ".", "real", "*", "z", ".", "real", "+", "z", ".", "imaginary", "*", "z", ".", "imaginary", ")", ";", "}" ]
Magnitude of complex number. @param z Complex number. @return Magnitude of complex number.
[ "Magnitude", "of", "complex", "number", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L302-L304
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Multiply
public static ComplexNumber Multiply(ComplexNumber z1, ComplexNumber z2) { double z1R = z1.real, z1I = z1.imaginary; double z2R = z2.real, z2I = z2.imaginary; return new ComplexNumber(z1R * z2R - z1I * z2I, z1R * z2I + z1I * z2R); }
java
public static ComplexNumber Multiply(ComplexNumber z1, ComplexNumber z2) { double z1R = z1.real, z1I = z1.imaginary; double z2R = z2.real, z2I = z2.imaginary; return new ComplexNumber(z1R * z2R - z1I * z2I, z1R * z2I + z1I * z2R); }
[ "public", "static", "ComplexNumber", "Multiply", "(", "ComplexNumber", "z1", ",", "ComplexNumber", "z2", ")", "{", "double", "z1R", "=", "z1", ".", "real", ",", "z1I", "=", "z1", ".", "imaginary", ";", "double", "z2R", "=", "z2", ".", "real", ",", "z2I", "=", "z2", ".", "imaginary", ";", "return", "new", "ComplexNumber", "(", "z1R", "*", "z2R", "-", "z1I", "*", "z2I", ",", "z1R", "*", "z2I", "+", "z1I", "*", "z2R", ")", ";", "}" ]
Multiply two complex numbers. @param z1 Complex Number. @param z2 Complex Number. @return Returns new ComplexNumber instance containing the multiply of specified complex numbers.
[ "Multiply", "two", "complex", "numbers", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L313-L318
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Multiply
public static ComplexNumber Multiply(ComplexNumber z1, double scalar) { return new ComplexNumber(z1.real * scalar, z1.imaginary * scalar); }
java
public static ComplexNumber Multiply(ComplexNumber z1, double scalar) { return new ComplexNumber(z1.real * scalar, z1.imaginary * scalar); }
[ "public", "static", "ComplexNumber", "Multiply", "(", "ComplexNumber", "z1", ",", "double", "scalar", ")", "{", "return", "new", "ComplexNumber", "(", "z1", ".", "real", "*", "scalar", ",", "z1", ".", "imaginary", "*", "scalar", ")", ";", "}" ]
Multiply scalar value to a complex number. @param z1 Complex Number. @param scalar Scalar value. @return Returns new ComplexNumber instance containing the multiply of specified complex number with the scalar value.
[ "Multiply", "scalar", "value", "to", "a", "complex", "number", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L327-L329
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Divide
public static ComplexNumber Divide(ComplexNumber z1, ComplexNumber z2) { ComplexNumber conj = ComplexNumber.Conjugate(z2); double a = z1.real * conj.real + ((z1.imaginary * conj.imaginary) * -1); double b = z1.real * conj.imaginary + (z1.imaginary * conj.real); double c = z2.real * conj.real + ((z2.imaginary * conj.imaginary) * -1); return new ComplexNumber(a / c, b / c); }
java
public static ComplexNumber Divide(ComplexNumber z1, ComplexNumber z2) { ComplexNumber conj = ComplexNumber.Conjugate(z2); double a = z1.real * conj.real + ((z1.imaginary * conj.imaginary) * -1); double b = z1.real * conj.imaginary + (z1.imaginary * conj.real); double c = z2.real * conj.real + ((z2.imaginary * conj.imaginary) * -1); return new ComplexNumber(a / c, b / c); }
[ "public", "static", "ComplexNumber", "Divide", "(", "ComplexNumber", "z1", ",", "ComplexNumber", "z2", ")", "{", "ComplexNumber", "conj", "=", "ComplexNumber", ".", "Conjugate", "(", "z2", ")", ";", "double", "a", "=", "z1", ".", "real", "*", "conj", ".", "real", "+", "(", "(", "z1", ".", "imaginary", "*", "conj", ".", "imaginary", ")", "*", "-", "1", ")", ";", "double", "b", "=", "z1", ".", "real", "*", "conj", ".", "imaginary", "+", "(", "z1", ".", "imaginary", "*", "conj", ".", "real", ")", ";", "double", "c", "=", "z2", ".", "real", "*", "conj", ".", "real", "+", "(", "(", "z2", ".", "imaginary", "*", "conj", ".", "imaginary", ")", "*", "-", "1", ")", ";", "return", "new", "ComplexNumber", "(", "a", "/", "c", ",", "b", "/", "c", ")", ";", "}" ]
Divide two complex numbers. @param z1 Complex Number. @param z2 Complex Number. @return Returns new ComplexNumber instance containing the divide of specified complex numbers.
[ "Divide", "two", "complex", "numbers", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L348-L358
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Pow
public static ComplexNumber Pow(ComplexNumber z1, double n) { double norm = Math.pow(z1.getMagnitude(), n); double angle = 360 - Math.abs(Math.toDegrees(Math.atan(z1.imaginary / z1.real))); double common = n * angle; double r = norm * Math.cos(Math.toRadians(common)); double i = norm * Math.sin(Math.toRadians(common)); return new ComplexNumber(r, i); }
java
public static ComplexNumber Pow(ComplexNumber z1, double n) { double norm = Math.pow(z1.getMagnitude(), n); double angle = 360 - Math.abs(Math.toDegrees(Math.atan(z1.imaginary / z1.real))); double common = n * angle; double r = norm * Math.cos(Math.toRadians(common)); double i = norm * Math.sin(Math.toRadians(common)); return new ComplexNumber(r, i); }
[ "public", "static", "ComplexNumber", "Pow", "(", "ComplexNumber", "z1", ",", "double", "n", ")", "{", "double", "norm", "=", "Math", ".", "pow", "(", "z1", ".", "getMagnitude", "(", ")", ",", "n", ")", ";", "double", "angle", "=", "360", "-", "Math", ".", "abs", "(", "Math", ".", "toDegrees", "(", "Math", ".", "atan", "(", "z1", ".", "imaginary", "/", "z1", ".", "real", ")", ")", ")", ";", "double", "common", "=", "n", "*", "angle", ";", "double", "r", "=", "norm", "*", "Math", ".", "cos", "(", "Math", ".", "toRadians", "(", "common", ")", ")", ";", "double", "i", "=", "norm", "*", "Math", ".", "sin", "(", "Math", ".", "toRadians", "(", "common", ")", ")", ";", "return", "new", "ComplexNumber", "(", "r", ",", "i", ")", ";", "}" ]
Calculate power of a complex number. @param z1 Complex Number. @param n Power. @return Returns a new complex number containing the power of a specified number.
[ "Calculate", "power", "of", "a", "complex", "number", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L414-L426
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Sin
public static ComplexNumber Sin(ComplexNumber z1) { ComplexNumber result = new ComplexNumber(); if (z1.imaginary == 0.0) { result.real = Math.sin(z1.real); result.imaginary = 0.0; } else { result.real = Math.sin(z1.real) * Math.cosh(z1.imaginary); result.imaginary = Math.cos(z1.real) * Math.sinh(z1.imaginary); } return result; }
java
public static ComplexNumber Sin(ComplexNumber z1) { ComplexNumber result = new ComplexNumber(); if (z1.imaginary == 0.0) { result.real = Math.sin(z1.real); result.imaginary = 0.0; } else { result.real = Math.sin(z1.real) * Math.cosh(z1.imaginary); result.imaginary = Math.cos(z1.real) * Math.sinh(z1.imaginary); } return result; }
[ "public", "static", "ComplexNumber", "Sin", "(", "ComplexNumber", "z1", ")", "{", "ComplexNumber", "result", "=", "new", "ComplexNumber", "(", ")", ";", "if", "(", "z1", ".", "imaginary", "==", "0.0", ")", "{", "result", ".", "real", "=", "Math", ".", "sin", "(", "z1", ".", "real", ")", ";", "result", ".", "imaginary", "=", "0.0", ";", "}", "else", "{", "result", ".", "real", "=", "Math", ".", "sin", "(", "z1", ".", "real", ")", "*", "Math", ".", "cosh", "(", "z1", ".", "imaginary", ")", ";", "result", ".", "imaginary", "=", "Math", ".", "cos", "(", "z1", ".", "real", ")", "*", "Math", ".", "sinh", "(", "z1", ".", "imaginary", ")", ";", "}", "return", "result", ";", "}" ]
Calculates Sine value of the complex number. @param z1 A Complex Number instance. @return Returns new ComplexNumber instance containing the Sine value of the specified complex number.
[ "Calculates", "Sine", "value", "of", "the", "complex", "number", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L491-L503
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/ComplexNumber.java
ComplexNumber.Tan
public static ComplexNumber Tan(ComplexNumber z1) { ComplexNumber result = new ComplexNumber(); if (z1.imaginary == 0.0) { result.real = Math.tan(z1.real); result.imaginary = 0.0; } else { double real2 = 2 * z1.real; double imag2 = 2 * z1.imaginary; double denom = Math.cos(real2) + Math.cosh(real2); result.real = Math.sin(real2) / denom; result.imaginary = Math.sinh(imag2) / denom; } return result; }
java
public static ComplexNumber Tan(ComplexNumber z1) { ComplexNumber result = new ComplexNumber(); if (z1.imaginary == 0.0) { result.real = Math.tan(z1.real); result.imaginary = 0.0; } else { double real2 = 2 * z1.real; double imag2 = 2 * z1.imaginary; double denom = Math.cos(real2) + Math.cosh(real2); result.real = Math.sin(real2) / denom; result.imaginary = Math.sinh(imag2) / denom; } return result; }
[ "public", "static", "ComplexNumber", "Tan", "(", "ComplexNumber", "z1", ")", "{", "ComplexNumber", "result", "=", "new", "ComplexNumber", "(", ")", ";", "if", "(", "z1", ".", "imaginary", "==", "0.0", ")", "{", "result", ".", "real", "=", "Math", ".", "tan", "(", "z1", ".", "real", ")", ";", "result", ".", "imaginary", "=", "0.0", ";", "}", "else", "{", "double", "real2", "=", "2", "*", "z1", ".", "real", ";", "double", "imag2", "=", "2", "*", "z1", ".", "imaginary", ";", "double", "denom", "=", "Math", ".", "cos", "(", "real2", ")", "+", "Math", ".", "cosh", "(", "real2", ")", ";", "result", ".", "real", "=", "Math", ".", "sin", "(", "real2", ")", "/", "denom", ";", "result", ".", "imaginary", "=", "Math", ".", "sinh", "(", "imag2", ")", "/", "denom", ";", "}", "return", "result", ";", "}" ]
Calculates Tangent value of the complex number. @param z1 A ComplexNumber instance. @return Returns new ComplexNumber instance containing the Tangent value of the specified complex number.
[ "Calculates", "Tangent", "value", "of", "the", "complex", "number", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L531-L547
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/random/UniversalGenerator.java
UniversalGenerator.srand
private void srand(int ijkl) { u = new double[97]; int ij = ijkl / 30082; int kl = ijkl % 30082; // Handle the seed range errors // First random number seed must be between 0 and 31328 // Second seed must have a value between 0 and 30081 if (ij < 0 || ij > 31328 || kl < 0 || kl > 30081) { ij = ij % 31329; kl = kl % 30082; } int i = ((ij / 177) % 177) + 2; int j = (ij % 177) + 2; int k = ((kl / 169) % 178) + 1; int l = kl % 169; int m; double s, t; for (int ii = 0; ii < 97; ii++) { s = 0.0; t = 0.5; for (int jj = 0; jj < 24; jj++) { m = (((i * j) % 179) * k) % 179; i = j; j = k; k = m; l = (53 * l + 1) % 169; if (((l * m) % 64) >= 32) { s += t; } t *= 0.5; } u[ii] = s; } c = 362436.0 / 16777216.0; cd = 7654321.0 / 16777216.0; cm = 16777213.0 / 16777216.0; i97 = 96; j97 = 32; }
java
private void srand(int ijkl) { u = new double[97]; int ij = ijkl / 30082; int kl = ijkl % 30082; // Handle the seed range errors // First random number seed must be between 0 and 31328 // Second seed must have a value between 0 and 30081 if (ij < 0 || ij > 31328 || kl < 0 || kl > 30081) { ij = ij % 31329; kl = kl % 30082; } int i = ((ij / 177) % 177) + 2; int j = (ij % 177) + 2; int k = ((kl / 169) % 178) + 1; int l = kl % 169; int m; double s, t; for (int ii = 0; ii < 97; ii++) { s = 0.0; t = 0.5; for (int jj = 0; jj < 24; jj++) { m = (((i * j) % 179) * k) % 179; i = j; j = k; k = m; l = (53 * l + 1) % 169; if (((l * m) % 64) >= 32) { s += t; } t *= 0.5; } u[ii] = s; } c = 362436.0 / 16777216.0; cd = 7654321.0 / 16777216.0; cm = 16777213.0 / 16777216.0; i97 = 96; j97 = 32; }
[ "private", "void", "srand", "(", "int", "ijkl", ")", "{", "u", "=", "new", "double", "[", "97", "]", ";", "int", "ij", "=", "ijkl", "/", "30082", ";", "int", "kl", "=", "ijkl", "%", "30082", ";", "// Handle the seed range errors", "// First random number seed must be between 0 and 31328", "// Second seed must have a value between 0 and 30081", "if", "(", "ij", "<", "0", "||", "ij", ">", "31328", "||", "kl", "<", "0", "||", "kl", ">", "30081", ")", "{", "ij", "=", "ij", "%", "31329", ";", "kl", "=", "kl", "%", "30082", ";", "}", "int", "i", "=", "(", "(", "ij", "/", "177", ")", "%", "177", ")", "+", "2", ";", "int", "j", "=", "(", "ij", "%", "177", ")", "+", "2", ";", "int", "k", "=", "(", "(", "kl", "/", "169", ")", "%", "178", ")", "+", "1", ";", "int", "l", "=", "kl", "%", "169", ";", "int", "m", ";", "double", "s", ",", "t", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "97", ";", "ii", "++", ")", "{", "s", "=", "0.0", ";", "t", "=", "0.5", ";", "for", "(", "int", "jj", "=", "0", ";", "jj", "<", "24", ";", "jj", "++", ")", "{", "m", "=", "(", "(", "(", "i", "*", "j", ")", "%", "179", ")", "*", "k", ")", "%", "179", ";", "i", "=", "j", ";", "j", "=", "k", ";", "k", "=", "m", ";", "l", "=", "(", "53", "*", "l", "+", "1", ")", "%", "169", ";", "if", "(", "(", "(", "l", "*", "m", ")", "%", "64", ")", ">=", "32", ")", "{", "s", "+=", "t", ";", "}", "t", "*=", "0.5", ";", "}", "u", "[", "ii", "]", "=", "s", ";", "}", "c", "=", "362436.0", "/", "16777216.0", ";", "cd", "=", "7654321.0", "/", "16777216.0", ";", "cm", "=", "16777213.0", "/", "16777216.0", ";", "i97", "=", "96", ";", "j97", "=", "32", ";", "}" ]
Initialize the random generator with a seed.
[ "Initialize", "the", "random", "generator", "with", "a", "seed", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/random/UniversalGenerator.java#L85-L128
train
Harium/keel
src/main/java/com/harium/keel/catalano/core/IntPoint.java
IntPoint.DistanceTo
public float DistanceTo(IntPoint anotherPoint) { float dx = this.x - anotherPoint.x; float dy = this.y - anotherPoint.y; return (float) Math.sqrt(dx * dx + dy * dy); }
java
public float DistanceTo(IntPoint anotherPoint) { float dx = this.x - anotherPoint.x; float dy = this.y - anotherPoint.y; return (float) Math.sqrt(dx * dx + dy * dy); }
[ "public", "float", "DistanceTo", "(", "IntPoint", "anotherPoint", ")", "{", "float", "dx", "=", "this", ".", "x", "-", "anotherPoint", ".", "x", ";", "float", "dy", "=", "this", ".", "y", "-", "anotherPoint", ".", "y", ";", "return", "(", "float", ")", "Math", ".", "sqrt", "(", "dx", "*", "dx", "+", "dy", "*", "dy", ")", ";", "}" ]
Calculate Euclidean distance between two points. @param anotherPoint Point to calculate distance to. @return Euclidean distance between this point and anotherPoint points.
[ "Calculate", "Euclidean", "distance", "between", "two", "points", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/core/IntPoint.java#L260-L265
train
Harium/keel
src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java
HistogramStatistics.Entropy
public static double Entropy( int[] values ){ int n = values.length; int total = 0; double entropy = 0; double p; // calculate total amount of hits for ( int i = 0; i < n; i++ ) { total += values[i]; } if ( total != 0 ) { // for all values for ( int i = 0; i < n; i++ ) { // get item's probability p = (double) values[i] / total; // calculate entropy if ( p != 0 ) entropy += ( -p * (Math.log10(p)/Math.log10(2)) ); } } return entropy; }
java
public static double Entropy( int[] values ){ int n = values.length; int total = 0; double entropy = 0; double p; // calculate total amount of hits for ( int i = 0; i < n; i++ ) { total += values[i]; } if ( total != 0 ) { // for all values for ( int i = 0; i < n; i++ ) { // get item's probability p = (double) values[i] / total; // calculate entropy if ( p != 0 ) entropy += ( -p * (Math.log10(p)/Math.log10(2)) ); } } return entropy; }
[ "public", "static", "double", "Entropy", "(", "int", "[", "]", "values", ")", "{", "int", "n", "=", "values", ".", "length", ";", "int", "total", "=", "0", ";", "double", "entropy", "=", "0", ";", "double", "p", ";", "// calculate total amount of hits", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "total", "+=", "values", "[", "i", "]", ";", "}", "if", "(", "total", "!=", "0", ")", "{", "// for all values", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "// get item's probability", "p", "=", "(", "double", ")", "values", "[", "i", "]", "/", "total", ";", "// calculate entropy", "if", "(", "p", "!=", "0", ")", "entropy", "+=", "(", "-", "p", "*", "(", "Math", ".", "log10", "(", "p", ")", "/", "Math", ".", "log10", "(", "2", ")", ")", ")", ";", "}", "}", "return", "entropy", ";", "}" ]
Calculate entropy value. @param values Values. @return Returns entropy value of the specified histogram array.
[ "Calculate", "entropy", "value", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java#L46-L71
train
Harium/keel
src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java
HistogramStatistics.GetRange
public static IntRange GetRange( int[] values, double percent ){ int total = 0, n = values.length; // for all values for ( int i = 0; i < n; i++ ) { // accumalate total total += values[i]; } int min, max, hits; int h = (int) ( total * ( percent + ( 1 - percent ) / 2 ) ); // get range min value for ( min = 0, hits = total; min < n; min++ ) { hits -= values[min]; if ( hits < h ) break; } // get range max value for ( max = n - 1, hits = total; max >= 0; max-- ) { hits -= values[max]; if ( hits < h ) break; } return new IntRange( min, max ); }
java
public static IntRange GetRange( int[] values, double percent ){ int total = 0, n = values.length; // for all values for ( int i = 0; i < n; i++ ) { // accumalate total total += values[i]; } int min, max, hits; int h = (int) ( total * ( percent + ( 1 - percent ) / 2 ) ); // get range min value for ( min = 0, hits = total; min < n; min++ ) { hits -= values[min]; if ( hits < h ) break; } // get range max value for ( max = n - 1, hits = total; max >= 0; max-- ) { hits -= values[max]; if ( hits < h ) break; } return new IntRange( min, max ); }
[ "public", "static", "IntRange", "GetRange", "(", "int", "[", "]", "values", ",", "double", "percent", ")", "{", "int", "total", "=", "0", ",", "n", "=", "values", ".", "length", ";", "// for all values", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "// accumalate total", "total", "+=", "values", "[", "i", "]", ";", "}", "int", "min", ",", "max", ",", "hits", ";", "int", "h", "=", "(", "int", ")", "(", "total", "*", "(", "percent", "+", "(", "1", "-", "percent", ")", "/", "2", ")", ")", ";", "// get range min value", "for", "(", "min", "=", "0", ",", "hits", "=", "total", ";", "min", "<", "n", ";", "min", "++", ")", "{", "hits", "-=", "values", "[", "min", "]", ";", "if", "(", "hits", "<", "h", ")", "break", ";", "}", "// get range max value", "for", "(", "max", "=", "n", "-", "1", ",", "hits", "=", "total", ";", "max", ">=", "0", ";", "max", "--", ")", "{", "hits", "-=", "values", "[", "max", "]", ";", "if", "(", "hits", "<", "h", ")", "break", ";", "}", "return", "new", "IntRange", "(", "min", ",", "max", ")", ";", "}" ]
Get range around median containing specified percentage of values. @param values Values. @param percent Values percentage around median. @return Returns the range which containes specifies percentage of values.
[ "Get", "range", "around", "median", "containing", "specified", "percentage", "of", "values", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java#L79-L107
train
Harium/keel
src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java
HistogramStatistics.Median
public static int Median( int[] values ){ int total = 0, n = values.length; // for all values for ( int i = 0; i < n; i++ ) { // accumalate total total += values[i]; } int halfTotal = total / 2; int median = 0, v = 0; // find median value for ( ; median < n; median++ ) { v += values[median]; if ( v >= halfTotal ) break; } return median; }
java
public static int Median( int[] values ){ int total = 0, n = values.length; // for all values for ( int i = 0; i < n; i++ ) { // accumalate total total += values[i]; } int halfTotal = total / 2; int median = 0, v = 0; // find median value for ( ; median < n; median++ ) { v += values[median]; if ( v >= halfTotal ) break; } return median; }
[ "public", "static", "int", "Median", "(", "int", "[", "]", "values", ")", "{", "int", "total", "=", "0", ",", "n", "=", "values", ".", "length", ";", "// for all values", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "// accumalate total", "total", "+=", "values", "[", "i", "]", ";", "}", "int", "halfTotal", "=", "total", "/", "2", ";", "int", "median", "=", "0", ",", "v", "=", "0", ";", "// find median value", "for", "(", ";", "median", "<", "n", ";", "median", "++", ")", "{", "v", "+=", "values", "[", "median", "]", ";", "if", "(", "v", ">=", "halfTotal", ")", "break", ";", "}", "return", "median", ";", "}" ]
Calculate Median value. @param values Values. @return Median.
[ "Calculate", "Median", "value", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java#L172-L194
train
Harium/keel
src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java
HistogramStatistics.Mode
public static int Mode( int[] values ){ int mode = 0, curMax = 0; for ( int i = 0, length = values.length; i < length; i++ ) { if ( values[i] > curMax ) { curMax = values[i]; mode = i; } } return mode; }
java
public static int Mode( int[] values ){ int mode = 0, curMax = 0; for ( int i = 0, length = values.length; i < length; i++ ) { if ( values[i] > curMax ) { curMax = values[i]; mode = i; } } return mode; }
[ "public", "static", "int", "Mode", "(", "int", "[", "]", "values", ")", "{", "int", "mode", "=", "0", ",", "curMax", "=", "0", ";", "for", "(", "int", "i", "=", "0", ",", "length", "=", "values", ".", "length", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "values", "[", "i", "]", ">", "curMax", ")", "{", "curMax", "=", "values", "[", "i", "]", ";", "mode", "=", "i", ";", "}", "}", "return", "mode", ";", "}" ]
Calculate Mode value. @param values Values. @return Returns mode value of the histogram array.
[ "Calculate", "Mode", "value", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java#L201-L213
train
Harium/keel
src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java
HistogramStatistics.StdDev
public static double StdDev( int[] values, double mean ){ double stddev = 0; double diff; int hits; int total = 0; // for all values for ( int i = 0, n = values.length; i < n; i++ ) { hits = values[i]; diff = (double) i - mean; // accumulate std.dev. stddev += diff * diff * hits; // accumalate total total += hits; } return ( total == 0 ) ? 0 : Math.sqrt( stddev / (total - 1) ); }
java
public static double StdDev( int[] values, double mean ){ double stddev = 0; double diff; int hits; int total = 0; // for all values for ( int i = 0, n = values.length; i < n; i++ ) { hits = values[i]; diff = (double) i - mean; // accumulate std.dev. stddev += diff * diff * hits; // accumalate total total += hits; } return ( total == 0 ) ? 0 : Math.sqrt( stddev / (total - 1) ); }
[ "public", "static", "double", "StdDev", "(", "int", "[", "]", "values", ",", "double", "mean", ")", "{", "double", "stddev", "=", "0", ";", "double", "diff", ";", "int", "hits", ";", "int", "total", "=", "0", ";", "// for all values", "for", "(", "int", "i", "=", "0", ",", "n", "=", "values", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "hits", "=", "values", "[", "i", "]", ";", "diff", "=", "(", "double", ")", "i", "-", "mean", ";", "// accumulate std.dev.", "stddev", "+=", "diff", "*", "diff", "*", "hits", ";", "// accumalate total", "total", "+=", "hits", ";", "}", "return", "(", "total", "==", "0", ")", "?", "0", ":", "Math", ".", "sqrt", "(", "stddev", "/", "(", "total", "-", "1", ")", ")", ";", "}" ]
Calculate standart deviation. @param values Values. @param mean Mean. @return Standart deviation.
[ "Calculate", "standart", "deviation", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java#L263-L281
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/transform/DiscreteCosineTransform.java
DiscreteCosineTransform.Forward
public static void Forward(double[] data) { double[] result = new double[data.length]; double sum; double scale = Math.sqrt(2.0 / data.length); for (int f = 0; f < data.length; f++) { sum = 0; for (int t = 0; t < data.length; t++) { double cos = Math.cos(((2.0 * t + 1.0) * f * Math.PI) / (2.0 * data.length)); sum += data[t] * cos * alpha(f); } result[f] = scale * sum; } for (int i = 0; i < data.length; i++) { data[i] = result[i]; } }
java
public static void Forward(double[] data) { double[] result = new double[data.length]; double sum; double scale = Math.sqrt(2.0 / data.length); for (int f = 0; f < data.length; f++) { sum = 0; for (int t = 0; t < data.length; t++) { double cos = Math.cos(((2.0 * t + 1.0) * f * Math.PI) / (2.0 * data.length)); sum += data[t] * cos * alpha(f); } result[f] = scale * sum; } for (int i = 0; i < data.length; i++) { data[i] = result[i]; } }
[ "public", "static", "void", "Forward", "(", "double", "[", "]", "data", ")", "{", "double", "[", "]", "result", "=", "new", "double", "[", "data", ".", "length", "]", ";", "double", "sum", ";", "double", "scale", "=", "Math", ".", "sqrt", "(", "2.0", "/", "data", ".", "length", ")", ";", "for", "(", "int", "f", "=", "0", ";", "f", "<", "data", ".", "length", ";", "f", "++", ")", "{", "sum", "=", "0", ";", "for", "(", "int", "t", "=", "0", ";", "t", "<", "data", ".", "length", ";", "t", "++", ")", "{", "double", "cos", "=", "Math", ".", "cos", "(", "(", "(", "2.0", "*", "t", "+", "1.0", ")", "*", "f", "*", "Math", ".", "PI", ")", "/", "(", "2.0", "*", "data", ".", "length", ")", ")", ";", "sum", "+=", "data", "[", "t", "]", "*", "cos", "*", "alpha", "(", "f", ")", ";", "}", "result", "[", "f", "]", "=", "scale", "*", "sum", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "data", "[", "i", "]", "=", "result", "[", "i", "]", ";", "}", "}" ]
1-D Forward Discrete Cosine Transform. @param data Data.
[ "1", "-", "D", "Forward", "Discrete", "Cosine", "Transform", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/transform/DiscreteCosineTransform.java#L45-L61
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/transform/DiscreteCosineTransform.java
DiscreteCosineTransform.Forward
public static void Forward(double[][] data) { int rows = data.length; int cols = data[0].length; double[] row = new double[cols]; double[] col = new double[rows]; for (int i = 0; i < rows; i++) { for (int j = 0; j < row.length; j++) row[j] = data[i][j]; Forward(row); for (int j = 0; j < row.length; j++) data[i][j] = row[j]; } for (int j = 0; j < cols; j++) { for (int i = 0; i < col.length; i++) col[i] = data[i][j]; Forward(col); for (int i = 0; i < col.length; i++) data[i][j] = col[i]; } }
java
public static void Forward(double[][] data) { int rows = data.length; int cols = data[0].length; double[] row = new double[cols]; double[] col = new double[rows]; for (int i = 0; i < rows; i++) { for (int j = 0; j < row.length; j++) row[j] = data[i][j]; Forward(row); for (int j = 0; j < row.length; j++) data[i][j] = row[j]; } for (int j = 0; j < cols; j++) { for (int i = 0; i < col.length; i++) col[i] = data[i][j]; Forward(col); for (int i = 0; i < col.length; i++) data[i][j] = col[i]; } }
[ "public", "static", "void", "Forward", "(", "double", "[", "]", "[", "]", "data", ")", "{", "int", "rows", "=", "data", ".", "length", ";", "int", "cols", "=", "data", "[", "0", "]", ".", "length", ";", "double", "[", "]", "row", "=", "new", "double", "[", "cols", "]", ";", "double", "[", "]", "col", "=", "new", "double", "[", "rows", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rows", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "row", ".", "length", ";", "j", "++", ")", "row", "[", "j", "]", "=", "data", "[", "i", "]", "[", "j", "]", ";", "Forward", "(", "row", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "row", ".", "length", ";", "j", "++", ")", "data", "[", "i", "]", "[", "j", "]", "=", "row", "[", "j", "]", ";", "}", "for", "(", "int", "j", "=", "0", ";", "j", "<", "cols", ";", "j", "++", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "col", ".", "length", ";", "i", "++", ")", "col", "[", "i", "]", "=", "data", "[", "i", "]", "[", "j", "]", ";", "Forward", "(", "col", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "col", ".", "length", ";", "i", "++", ")", "data", "[", "i", "]", "[", "j", "]", "=", "col", "[", "i", "]", ";", "}", "}" ]
2-D Forward Discrete Cosine Transform. @param data Data.
[ "2", "-", "D", "Forward", "Discrete", "Cosine", "Transform", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/transform/DiscreteCosineTransform.java#L68-L94
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/transform/DiscreteCosineTransform.java
DiscreteCosineTransform.Backward
public static void Backward(double[] data) { double[] result = new double[data.length]; double sum; double scale = Math.sqrt(2.0 / data.length); for (int t = 0; t < data.length; t++) { sum = 0; for (int j = 0; j < data.length; j++) { double cos = Math.cos(((2 * t + 1) * j * Math.PI) / (2 * data.length)); sum += alpha(j) * data[j] * cos; } result[t] = scale * sum; } for (int i = 0; i < data.length; i++) { data[i] = result[i]; } }
java
public static void Backward(double[] data) { double[] result = new double[data.length]; double sum; double scale = Math.sqrt(2.0 / data.length); for (int t = 0; t < data.length; t++) { sum = 0; for (int j = 0; j < data.length; j++) { double cos = Math.cos(((2 * t + 1) * j * Math.PI) / (2 * data.length)); sum += alpha(j) * data[j] * cos; } result[t] = scale * sum; } for (int i = 0; i < data.length; i++) { data[i] = result[i]; } }
[ "public", "static", "void", "Backward", "(", "double", "[", "]", "data", ")", "{", "double", "[", "]", "result", "=", "new", "double", "[", "data", ".", "length", "]", ";", "double", "sum", ";", "double", "scale", "=", "Math", ".", "sqrt", "(", "2.0", "/", "data", ".", "length", ")", ";", "for", "(", "int", "t", "=", "0", ";", "t", "<", "data", ".", "length", ";", "t", "++", ")", "{", "sum", "=", "0", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "data", ".", "length", ";", "j", "++", ")", "{", "double", "cos", "=", "Math", ".", "cos", "(", "(", "(", "2", "*", "t", "+", "1", ")", "*", "j", "*", "Math", ".", "PI", ")", "/", "(", "2", "*", "data", ".", "length", ")", ")", ";", "sum", "+=", "alpha", "(", "j", ")", "*", "data", "[", "j", "]", "*", "cos", ";", "}", "result", "[", "t", "]", "=", "scale", "*", "sum", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "data", "[", "i", "]", "=", "result", "[", "i", "]", ";", "}", "}" ]
1-D Backward Discrete Cosine Transform. @param data Data.
[ "1", "-", "D", "Backward", "Discrete", "Cosine", "Transform", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/transform/DiscreteCosineTransform.java#L101-L117
train
Harium/keel
src/main/java/com/harium/keel/effect/LevelsLinear.java
LevelsLinear.setInRGB
public void setInRGB(IntRange inRGB) { this.inRed = inRGB; this.inGreen = inRGB; this.inBlue = inRGB; CalculateMap(inRGB, outRed, mapRed); CalculateMap(inRGB, outGreen, mapGreen); CalculateMap(inRGB, outBlue, mapBlue); }
java
public void setInRGB(IntRange inRGB) { this.inRed = inRGB; this.inGreen = inRGB; this.inBlue = inRGB; CalculateMap(inRGB, outRed, mapRed); CalculateMap(inRGB, outGreen, mapGreen); CalculateMap(inRGB, outBlue, mapBlue); }
[ "public", "void", "setInRGB", "(", "IntRange", "inRGB", ")", "{", "this", ".", "inRed", "=", "inRGB", ";", "this", ".", "inGreen", "=", "inRGB", ";", "this", ".", "inBlue", "=", "inRGB", ";", "CalculateMap", "(", "inRGB", ",", "outRed", ",", "mapRed", ")", ";", "CalculateMap", "(", "inRGB", ",", "outGreen", ",", "mapGreen", ")", ";", "CalculateMap", "(", "inRGB", ",", "outBlue", ",", "mapBlue", ")", ";", "}" ]
Set RGB input range. @param inRGB Range.
[ "Set", "RGB", "input", "range", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/effect/LevelsLinear.java#L222-L230
train
Harium/keel
src/main/java/com/harium/keel/effect/LevelsLinear.java
LevelsLinear.setOutRGB
public void setOutRGB(IntRange outRGB) { this.outRed = outRGB; this.outGreen = outRGB; this.outBlue = outRGB; CalculateMap(inRed, outRGB, mapRed); CalculateMap(inGreen, outRGB, mapGreen); CalculateMap(inBlue, outRGB, mapBlue); }
java
public void setOutRGB(IntRange outRGB) { this.outRed = outRGB; this.outGreen = outRGB; this.outBlue = outRGB; CalculateMap(inRed, outRGB, mapRed); CalculateMap(inGreen, outRGB, mapGreen); CalculateMap(inBlue, outRGB, mapBlue); }
[ "public", "void", "setOutRGB", "(", "IntRange", "outRGB", ")", "{", "this", ".", "outRed", "=", "outRGB", ";", "this", ".", "outGreen", "=", "outRGB", ";", "this", ".", "outBlue", "=", "outRGB", ";", "CalculateMap", "(", "inRed", ",", "outRGB", ",", "mapRed", ")", ";", "CalculateMap", "(", "inGreen", ",", "outRGB", ",", "mapGreen", ")", ";", "CalculateMap", "(", "inBlue", ",", "outRGB", ",", "mapBlue", ")", ";", "}" ]
Set RGB output range. @param outRGB Range.
[ "Set", "RGB", "output", "range", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/effect/LevelsLinear.java#L237-L245
train
Harium/keel
src/main/java/com/harium/keel/effect/LevelsLinear.java
LevelsLinear.CalculateMap
private void CalculateMap(IntRange inRange, IntRange outRange, int[] map) { double k = 0, b = 0; if (inRange.getMax() != inRange.getMin()) { k = (double) (outRange.getMax() - outRange.getMin()) / (double) (inRange.getMax() - inRange.getMin()); b = (double) (outRange.getMin()) - k * inRange.getMin(); } for (int i = 0; i < 256; i++) { int v = (int) i; if (v >= inRange.getMax()) v = outRange.getMax(); else if (v <= inRange.getMin()) v = outRange.getMin(); else v = (int) (k * v + b); map[i] = v; } }
java
private void CalculateMap(IntRange inRange, IntRange outRange, int[] map) { double k = 0, b = 0; if (inRange.getMax() != inRange.getMin()) { k = (double) (outRange.getMax() - outRange.getMin()) / (double) (inRange.getMax() - inRange.getMin()); b = (double) (outRange.getMin()) - k * inRange.getMin(); } for (int i = 0; i < 256; i++) { int v = (int) i; if (v >= inRange.getMax()) v = outRange.getMax(); else if (v <= inRange.getMin()) v = outRange.getMin(); else v = (int) (k * v + b); map[i] = v; } }
[ "private", "void", "CalculateMap", "(", "IntRange", "inRange", ",", "IntRange", "outRange", ",", "int", "[", "]", "map", ")", "{", "double", "k", "=", "0", ",", "b", "=", "0", ";", "if", "(", "inRange", ".", "getMax", "(", ")", "!=", "inRange", ".", "getMin", "(", ")", ")", "{", "k", "=", "(", "double", ")", "(", "outRange", ".", "getMax", "(", ")", "-", "outRange", ".", "getMin", "(", ")", ")", "/", "(", "double", ")", "(", "inRange", ".", "getMax", "(", ")", "-", "inRange", ".", "getMin", "(", ")", ")", ";", "b", "=", "(", "double", ")", "(", "outRange", ".", "getMin", "(", ")", ")", "-", "k", "*", "inRange", ".", "getMin", "(", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "256", ";", "i", "++", ")", "{", "int", "v", "=", "(", "int", ")", "i", ";", "if", "(", "v", ">=", "inRange", ".", "getMax", "(", ")", ")", "v", "=", "outRange", ".", "getMax", "(", ")", ";", "else", "if", "(", "v", "<=", "inRange", ".", "getMin", "(", ")", ")", "v", "=", "outRange", ".", "getMin", "(", ")", ";", "else", "v", "=", "(", "int", ")", "(", "k", "*", "v", "+", "b", ")", ";", "map", "[", "i", "]", "=", "v", ";", "}", "}" ]
Calculate conversion map. @param inRange Input range. @param outRange Output range. @param map Conversion map.
[ "Calculate", "conversion", "map", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/effect/LevelsLinear.java#L285-L305
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/tools/ImageStatistics.java
ImageStatistics.Maximum
public static int Maximum(ImageSource fastBitmap, int startX, int startY, int width, int height) { int max = 0; if (fastBitmap.isGrayscale()) { for (int i = startX; i < height; i++) { for (int j = startY; j < width; j++) { int gray = fastBitmap.getRGB(j, i); if (gray > max) { max = gray; } } } } else { for (int i = startX; i < height; i++) { for (int j = startY; j < width; j++) { int gray = fastBitmap.getG(j, i); if (gray > max) { max = gray; } } } } return max; }
java
public static int Maximum(ImageSource fastBitmap, int startX, int startY, int width, int height) { int max = 0; if (fastBitmap.isGrayscale()) { for (int i = startX; i < height; i++) { for (int j = startY; j < width; j++) { int gray = fastBitmap.getRGB(j, i); if (gray > max) { max = gray; } } } } else { for (int i = startX; i < height; i++) { for (int j = startY; j < width; j++) { int gray = fastBitmap.getG(j, i); if (gray > max) { max = gray; } } } } return max; }
[ "public", "static", "int", "Maximum", "(", "ImageSource", "fastBitmap", ",", "int", "startX", ",", "int", "startY", ",", "int", "width", ",", "int", "height", ")", "{", "int", "max", "=", "0", ";", "if", "(", "fastBitmap", ".", "isGrayscale", "(", ")", ")", "{", "for", "(", "int", "i", "=", "startX", ";", "i", "<", "height", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "startY", ";", "j", "<", "width", ";", "j", "++", ")", "{", "int", "gray", "=", "fastBitmap", ".", "getRGB", "(", "j", ",", "i", ")", ";", "if", "(", "gray", ">", "max", ")", "{", "max", "=", "gray", ";", "}", "}", "}", "}", "else", "{", "for", "(", "int", "i", "=", "startX", ";", "i", "<", "height", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "startY", ";", "j", "<", "width", ";", "j", "++", ")", "{", "int", "gray", "=", "fastBitmap", ".", "getG", "(", "j", ",", "i", ")", ";", "if", "(", "gray", ">", "max", ")", "{", "max", "=", "gray", ";", "}", "}", "}", "}", "return", "max", ";", "}" ]
Get maximum gray value in the image. @param fastBitmap Image to be processed. @param startX Initial X axis coordinate. @param startY Initial Y axis coordinate. @param width Width. @param height Height. @return Maximum gray.
[ "Get", "maximum", "gray", "value", "in", "the", "image", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/tools/ImageStatistics.java#L263-L287
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/tools/ImageStatistics.java
ImageStatistics.Minimum
public static int Minimum(ImageSource fastBitmap, int startX, int startY, int width, int height) { int min = 255; if (fastBitmap.isGrayscale()) { for (int i = startX; i < height; i++) { for (int j = startY; j < width; j++) { int gray = fastBitmap.getRGB(j, i); if (gray < min) { min = gray; } } } } else { for (int i = startX; i < height; i++) { for (int j = startY; j < width; j++) { int gray = fastBitmap.getG(j, i); if (gray < min) { min = gray; } } } } return min; }
java
public static int Minimum(ImageSource fastBitmap, int startX, int startY, int width, int height) { int min = 255; if (fastBitmap.isGrayscale()) { for (int i = startX; i < height; i++) { for (int j = startY; j < width; j++) { int gray = fastBitmap.getRGB(j, i); if (gray < min) { min = gray; } } } } else { for (int i = startX; i < height; i++) { for (int j = startY; j < width; j++) { int gray = fastBitmap.getG(j, i); if (gray < min) { min = gray; } } } } return min; }
[ "public", "static", "int", "Minimum", "(", "ImageSource", "fastBitmap", ",", "int", "startX", ",", "int", "startY", ",", "int", "width", ",", "int", "height", ")", "{", "int", "min", "=", "255", ";", "if", "(", "fastBitmap", ".", "isGrayscale", "(", ")", ")", "{", "for", "(", "int", "i", "=", "startX", ";", "i", "<", "height", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "startY", ";", "j", "<", "width", ";", "j", "++", ")", "{", "int", "gray", "=", "fastBitmap", ".", "getRGB", "(", "j", ",", "i", ")", ";", "if", "(", "gray", "<", "min", ")", "{", "min", "=", "gray", ";", "}", "}", "}", "}", "else", "{", "for", "(", "int", "i", "=", "startX", ";", "i", "<", "height", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "startY", ";", "j", "<", "width", ";", "j", "++", ")", "{", "int", "gray", "=", "fastBitmap", ".", "getG", "(", "j", ",", "i", ")", ";", "if", "(", "gray", "<", "min", ")", "{", "min", "=", "gray", ";", "}", "}", "}", "}", "return", "min", ";", "}" ]
Get minimum gray value in the image. @param fastBitmap Image to be processed. @param startX Initial X axis coordinate. @param startY Initial Y axis coordinate. @param width Width. @param height Height. @return Minimum gray.
[ "Get", "minimum", "gray", "value", "in", "the", "image", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/tools/ImageStatistics.java#L309-L331
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.Bhattacharyya
public static double Bhattacharyya(double[] histogram1, double[] histogram2) { int bins = histogram1.length; // histogram bins double b = 0; // Bhattacharyya's coefficient for (int i = 0; i < bins; i++) b += Math.sqrt(histogram1[i]) * Math.sqrt(histogram2[i]); // Bhattacharyya distance between the two distributions return Math.sqrt(1.0 - b); }
java
public static double Bhattacharyya(double[] histogram1, double[] histogram2) { int bins = histogram1.length; // histogram bins double b = 0; // Bhattacharyya's coefficient for (int i = 0; i < bins; i++) b += Math.sqrt(histogram1[i]) * Math.sqrt(histogram2[i]); // Bhattacharyya distance between the two distributions return Math.sqrt(1.0 - b); }
[ "public", "static", "double", "Bhattacharyya", "(", "double", "[", "]", "histogram1", ",", "double", "[", "]", "histogram2", ")", "{", "int", "bins", "=", "histogram1", ".", "length", ";", "// histogram bins", "double", "b", "=", "0", ";", "// Bhattacharyya's coefficient", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bins", ";", "i", "++", ")", "b", "+=", "Math", ".", "sqrt", "(", "histogram1", "[", "i", "]", ")", "*", "Math", ".", "sqrt", "(", "histogram2", "[", "i", "]", ")", ";", "// Bhattacharyya distance between the two distributions", "return", "Math", ".", "sqrt", "(", "1.0", "-", "b", ")", ";", "}" ]
Bhattacharyya distance between two normalized histograms. @param histogram1 Normalized histogram. @param histogram2 Normalized histogram. @return The Bhattacharyya distance between the two histograms.
[ "Bhattacharyya", "distance", "between", "two", "normalized", "histograms", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L68-L77
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.ChiSquare
public static double ChiSquare(double[] histogram1, double[] histogram2) { double r = 0; for (int i = 0; i < histogram1.length; i++) { double t = histogram1[i] + histogram2[i]; if (t != 0) r += Math.pow(histogram1[i] - histogram2[i], 2) / t; } return 0.5 * r; }
java
public static double ChiSquare(double[] histogram1, double[] histogram2) { double r = 0; for (int i = 0; i < histogram1.length; i++) { double t = histogram1[i] + histogram2[i]; if (t != 0) r += Math.pow(histogram1[i] - histogram2[i], 2) / t; } return 0.5 * r; }
[ "public", "static", "double", "ChiSquare", "(", "double", "[", "]", "histogram1", ",", "double", "[", "]", "histogram2", ")", "{", "double", "r", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "histogram1", ".", "length", ";", "i", "++", ")", "{", "double", "t", "=", "histogram1", "[", "i", "]", "+", "histogram2", "[", "i", "]", ";", "if", "(", "t", "!=", "0", ")", "r", "+=", "Math", ".", "pow", "(", "histogram1", "[", "i", "]", "-", "histogram2", "[", "i", "]", ",", "2", ")", "/", "t", ";", "}", "return", "0.5", "*", "r", ";", "}" ]
Gets the Chi Square distance between two normalized histograms. @param histogram1 Histogram. @param histogram2 Histogram. @return The Chi Square distance between x and y.
[ "Gets", "the", "Chi", "Square", "distance", "between", "two", "normalized", "histograms", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L265-L274
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.Correlation
public static double Correlation(double[] p, double[] q) { double x = 0; double y = 0; for (int i = 0; i < p.length; i++) { x += -p[i]; y += -q[i]; } x /= p.length; y /= q.length; double num = 0; double den1 = 0; double den2 = 0; for (int i = 0; i < p.length; i++) { num += (p[i] + x) * (q[i] + y); den1 += Math.abs(Math.pow(p[i] + x, 2)); den2 += Math.abs(Math.pow(q[i] + x, 2)); } return 1 - (num / (Math.sqrt(den1) * Math.sqrt(den2))); }
java
public static double Correlation(double[] p, double[] q) { double x = 0; double y = 0; for (int i = 0; i < p.length; i++) { x += -p[i]; y += -q[i]; } x /= p.length; y /= q.length; double num = 0; double den1 = 0; double den2 = 0; for (int i = 0; i < p.length; i++) { num += (p[i] + x) * (q[i] + y); den1 += Math.abs(Math.pow(p[i] + x, 2)); den2 += Math.abs(Math.pow(q[i] + x, 2)); } return 1 - (num / (Math.sqrt(den1) * Math.sqrt(den2))); }
[ "public", "static", "double", "Correlation", "(", "double", "[", "]", "p", ",", "double", "[", "]", "q", ")", "{", "double", "x", "=", "0", ";", "double", "y", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ".", "length", ";", "i", "++", ")", "{", "x", "+=", "-", "p", "[", "i", "]", ";", "y", "+=", "-", "q", "[", "i", "]", ";", "}", "x", "/=", "p", ".", "length", ";", "y", "/=", "q", ".", "length", ";", "double", "num", "=", "0", ";", "double", "den1", "=", "0", ";", "double", "den2", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ".", "length", ";", "i", "++", ")", "{", "num", "+=", "(", "p", "[", "i", "]", "+", "x", ")", "*", "(", "q", "[", "i", "]", "+", "y", ")", ";", "den1", "+=", "Math", ".", "abs", "(", "Math", ".", "pow", "(", "p", "[", "i", "]", "+", "x", ",", "2", ")", ")", ";", "den2", "+=", "Math", ".", "abs", "(", "Math", ".", "pow", "(", "q", "[", "i", "]", "+", "x", ",", "2", ")", ")", ";", "}", "return", "1", "-", "(", "num", "/", "(", "Math", ".", "sqrt", "(", "den1", ")", "*", "Math", ".", "sqrt", "(", "den2", ")", ")", ")", ";", "}" ]
Gets the Correlation distance between two points. @param p A point in space. @param q A point in space. @return The Correlation distance between x and y.
[ "Gets", "the", "Correlation", "distance", "between", "two", "points", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L283-L308
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.Hamming
public static int Hamming(String first, String second) { if (first.length() != second.length()) throw new IllegalArgumentException("The size of string must be the same."); int diff = 0; for (int i = 0; i < first.length(); i++) if (first.charAt(i) != second.charAt(i)) diff++; return diff; }
java
public static int Hamming(String first, String second) { if (first.length() != second.length()) throw new IllegalArgumentException("The size of string must be the same."); int diff = 0; for (int i = 0; i < first.length(); i++) if (first.charAt(i) != second.charAt(i)) diff++; return diff; }
[ "public", "static", "int", "Hamming", "(", "String", "first", ",", "String", "second", ")", "{", "if", "(", "first", ".", "length", "(", ")", "!=", "second", ".", "length", "(", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"The size of string must be the same.\"", ")", ";", "int", "diff", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "first", ".", "length", "(", ")", ";", "i", "++", ")", "if", "(", "first", ".", "charAt", "(", "i", ")", "!=", "second", ".", "charAt", "(", "i", ")", ")", "diff", "++", ";", "return", "diff", ";", "}" ]
Gets the Hamming distance between two strings. @param first First string. @param second Second string. @return The Hamming distance between p and q.
[ "Gets", "the", "Hamming", "distance", "between", "two", "strings", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L412-L422
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.JaccardDistance
public static double JaccardDistance(double[] p, double[] q) { double distance = 0; int intersection = 0, union = 0; for (int x = 0; x < p.length; x++) { if ((p[x] != 0) || (q[x] != 0)) { if (p[x] == q[x]) { intersection++; } union++; } } if (union != 0) distance = 1.0 - ((double) intersection / (double) union); else distance = 0; return distance; }
java
public static double JaccardDistance(double[] p, double[] q) { double distance = 0; int intersection = 0, union = 0; for (int x = 0; x < p.length; x++) { if ((p[x] != 0) || (q[x] != 0)) { if (p[x] == q[x]) { intersection++; } union++; } } if (union != 0) distance = 1.0 - ((double) intersection / (double) union); else distance = 0; return distance; }
[ "public", "static", "double", "JaccardDistance", "(", "double", "[", "]", "p", ",", "double", "[", "]", "q", ")", "{", "double", "distance", "=", "0", ";", "int", "intersection", "=", "0", ",", "union", "=", "0", ";", "for", "(", "int", "x", "=", "0", ";", "x", "<", "p", ".", "length", ";", "x", "++", ")", "{", "if", "(", "(", "p", "[", "x", "]", "!=", "0", ")", "||", "(", "q", "[", "x", "]", "!=", "0", ")", ")", "{", "if", "(", "p", "[", "x", "]", "==", "q", "[", "x", "]", ")", "{", "intersection", "++", ";", "}", "union", "++", ";", "}", "}", "if", "(", "union", "!=", "0", ")", "distance", "=", "1.0", "-", "(", "(", "double", ")", "intersection", "/", "(", "double", ")", "union", ")", ";", "else", "distance", "=", "0", ";", "return", "distance", ";", "}" ]
Gets the Jaccard distance between two points. @param p A point in space. @param q A point in space. @return The Jaccard distance between x and y.
[ "Gets", "the", "Jaccard", "distance", "between", "two", "points", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L431-L451
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.JensenShannonDivergence
public static double JensenShannonDivergence(double[] p, double[] q) { double[] m = new double[p.length]; for (int i = 0; i < m.length; i++) { m[i] = (p[i] + q[i]) / 2; } return (KullbackLeiblerDivergence(p, m) + KullbackLeiblerDivergence(q, m)) / 2; }
java
public static double JensenShannonDivergence(double[] p, double[] q) { double[] m = new double[p.length]; for (int i = 0; i < m.length; i++) { m[i] = (p[i] + q[i]) / 2; } return (KullbackLeiblerDivergence(p, m) + KullbackLeiblerDivergence(q, m)) / 2; }
[ "public", "static", "double", "JensenShannonDivergence", "(", "double", "[", "]", "p", ",", "double", "[", "]", "q", ")", "{", "double", "[", "]", "m", "=", "new", "double", "[", "p", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "m", ".", "length", ";", "i", "++", ")", "{", "m", "[", "i", "]", "=", "(", "p", "[", "i", "]", "+", "q", "[", "i", "]", ")", "/", "2", ";", "}", "return", "(", "KullbackLeiblerDivergence", "(", "p", ",", "m", ")", "+", "KullbackLeiblerDivergence", "(", "q", ",", "m", ")", ")", "/", "2", ";", "}" ]
Gets the Jensen Shannon divergence. @param p U vector. @param q V vector. @return The Jensen Shannon divergence between u and v.
[ "Gets", "the", "Jensen", "Shannon", "divergence", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L509-L516
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.KumarJohnsonDivergence
public static double KumarJohnsonDivergence(double[] p, double[] q) { double r = 0; for (int i = 0; i < p.length; i++) { if (p[i] != 0 && q[i] != 0) { r += Math.pow(p[i] * p[i] - q[i] * q[i], 2) / 2 * Math.pow(p[i] * q[i], 1.5); } } return r; }
java
public static double KumarJohnsonDivergence(double[] p, double[] q) { double r = 0; for (int i = 0; i < p.length; i++) { if (p[i] != 0 && q[i] != 0) { r += Math.pow(p[i] * p[i] - q[i] * q[i], 2) / 2 * Math.pow(p[i] * q[i], 1.5); } } return r; }
[ "public", "static", "double", "KumarJohnsonDivergence", "(", "double", "[", "]", "p", ",", "double", "[", "]", "q", ")", "{", "double", "r", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ".", "length", ";", "i", "++", ")", "{", "if", "(", "p", "[", "i", "]", "!=", "0", "&&", "q", "[", "i", "]", "!=", "0", ")", "{", "r", "+=", "Math", ".", "pow", "(", "p", "[", "i", "]", "*", "p", "[", "i", "]", "-", "q", "[", "i", "]", "*", "q", "[", "i", "]", ",", "2", ")", "/", "2", "*", "Math", ".", "pow", "(", "p", "[", "i", "]", "*", "q", "[", "i", "]", ",", "1.5", ")", ";", "}", "}", "return", "r", ";", "}" ]
Gets the Kumar-Johnson divergence. @param p P vector. @param q Q vector. @return The Kumar-Johnson divergence between p and q.
[ "Gets", "the", "Kumar", "-", "Johnson", "divergence", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L543-L551
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.KullbackLeiblerDivergence
public static double KullbackLeiblerDivergence(double[] p, double[] q) { boolean intersection = false; double k = 0; for (int i = 0; i < p.length; i++) { if (p[i] != 0 && q[i] != 0) { intersection = true; k += p[i] * Math.log(p[i] / q[i]); } } if (intersection) return k; else return Double.POSITIVE_INFINITY; }
java
public static double KullbackLeiblerDivergence(double[] p, double[] q) { boolean intersection = false; double k = 0; for (int i = 0; i < p.length; i++) { if (p[i] != 0 && q[i] != 0) { intersection = true; k += p[i] * Math.log(p[i] / q[i]); } } if (intersection) return k; else return Double.POSITIVE_INFINITY; }
[ "public", "static", "double", "KullbackLeiblerDivergence", "(", "double", "[", "]", "p", ",", "double", "[", "]", "q", ")", "{", "boolean", "intersection", "=", "false", ";", "double", "k", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ".", "length", ";", "i", "++", ")", "{", "if", "(", "p", "[", "i", "]", "!=", "0", "&&", "q", "[", "i", "]", "!=", "0", ")", "{", "intersection", "=", "true", ";", "k", "+=", "p", "[", "i", "]", "*", "Math", ".", "log", "(", "p", "[", "i", "]", "/", "q", "[", "i", "]", ")", ";", "}", "}", "if", "(", "intersection", ")", "return", "k", ";", "else", "return", "Double", ".", "POSITIVE_INFINITY", ";", "}" ]
Gets the Kullback Leibler divergence. @param p P vector. @param q Q vector. @return The Kullback Leibler divergence between u and v.
[ "Gets", "the", "Kullback", "Leibler", "divergence", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L560-L575
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.SquaredEuclidean
public static double SquaredEuclidean(double[] x, double[] y) { double d = 0.0, u; for (int i = 0; i < x.length; i++) { u = x[i] - y[i]; d += u * u; } return d; }
java
public static double SquaredEuclidean(double[] x, double[] y) { double d = 0.0, u; for (int i = 0; i < x.length; i++) { u = x[i] - y[i]; d += u * u; } return d; }
[ "public", "static", "double", "SquaredEuclidean", "(", "double", "[", "]", "x", ",", "double", "[", "]", "y", ")", "{", "double", "d", "=", "0.0", ",", "u", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "x", ".", "length", ";", "i", "++", ")", "{", "u", "=", "x", "[", "i", "]", "-", "y", "[", "i", "]", ";", "d", "+=", "u", "*", "u", ";", "}", "return", "d", ";", "}" ]
Gets the Square Euclidean distance between two points. @param x A point in space. @param y A point in space. @return The Square Euclidean distance between x and y.
[ "Gets", "the", "Square", "Euclidean", "distance", "between", "two", "points", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L801-L810
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.SymmetricChiSquareDivergence
public static double SymmetricChiSquareDivergence(double[] p, double[] q) { double r = 0; for (int i = 0; i < p.length; i++) { double den = p[i] * q[i]; if (den != 0) { double p1 = p[i] - q[i]; double p2 = p[i] + q[i]; r += (p1 * p1 * p2) / den; } } return r; }
java
public static double SymmetricChiSquareDivergence(double[] p, double[] q) { double r = 0; for (int i = 0; i < p.length; i++) { double den = p[i] * q[i]; if (den != 0) { double p1 = p[i] - q[i]; double p2 = p[i] + q[i]; r += (p1 * p1 * p2) / den; } } return r; }
[ "public", "static", "double", "SymmetricChiSquareDivergence", "(", "double", "[", "]", "p", ",", "double", "[", "]", "q", ")", "{", "double", "r", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ".", "length", ";", "i", "++", ")", "{", "double", "den", "=", "p", "[", "i", "]", "*", "q", "[", "i", "]", ";", "if", "(", "den", "!=", "0", ")", "{", "double", "p1", "=", "p", "[", "i", "]", "-", "q", "[", "i", "]", ";", "double", "p2", "=", "p", "[", "i", "]", "+", "q", "[", "i", "]", ";", "r", "+=", "(", "p1", "*", "p1", "*", "p2", ")", "/", "den", ";", "}", "}", "return", "r", ";", "}" ]
Gets the Symmetric Chi-square divergence. @param p P vector. @param q Q vector. @return The Symmetric chi-square divergence between p and q.
[ "Gets", "the", "Symmetric", "Chi", "-", "square", "divergence", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L851-L863
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.SymmetricKullbackLeibler
public static double SymmetricKullbackLeibler(double[] p, double[] q) { double dist = 0; for (int i = 0; i < p.length; i++) { dist += (p[i] - q[i]) * (Math.log(p[i]) - Math.log(q[i])); } return dist; }
java
public static double SymmetricKullbackLeibler(double[] p, double[] q) { double dist = 0; for (int i = 0; i < p.length; i++) { dist += (p[i] - q[i]) * (Math.log(p[i]) - Math.log(q[i])); } return dist; }
[ "public", "static", "double", "SymmetricKullbackLeibler", "(", "double", "[", "]", "p", ",", "double", "[", "]", "q", ")", "{", "double", "dist", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ".", "length", ";", "i", "++", ")", "{", "dist", "+=", "(", "p", "[", "i", "]", "-", "q", "[", "i", "]", ")", "*", "(", "Math", ".", "log", "(", "p", "[", "i", "]", ")", "-", "Math", ".", "log", "(", "q", "[", "i", "]", ")", ")", ";", "}", "return", "dist", ";", "}" ]
Gets the Symmetric Kullback-Leibler distance. This metric is valid only for real and positive P and Q. @param p P vector. @param q Q vector. @return The Symmetric Kullback Leibler distance between p and q.
[ "Gets", "the", "Symmetric", "Kullback", "-", "Leibler", "distance", ".", "This", "metric", "is", "valid", "only", "for", "real", "and", "positive", "P", "and", "Q", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L873-L880
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.Taneja
public static double Taneja(double[] p, double[] q) { double r = 0; for (int i = 0; i < p.length; i++) { if (p[i] != 0 && q[i] != 0) { double pq = p[i] + q[i]; r += (pq / 2) * Math.log(pq / (2 * Math.sqrt(p[i] * q[i]))); } } return r; }
java
public static double Taneja(double[] p, double[] q) { double r = 0; for (int i = 0; i < p.length; i++) { if (p[i] != 0 && q[i] != 0) { double pq = p[i] + q[i]; r += (pq / 2) * Math.log(pq / (2 * Math.sqrt(p[i] * q[i]))); } } return r; }
[ "public", "static", "double", "Taneja", "(", "double", "[", "]", "p", ",", "double", "[", "]", "q", ")", "{", "double", "r", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ".", "length", ";", "i", "++", ")", "{", "if", "(", "p", "[", "i", "]", "!=", "0", "&&", "q", "[", "i", "]", "!=", "0", ")", "{", "double", "pq", "=", "p", "[", "i", "]", "+", "q", "[", "i", "]", ";", "r", "+=", "(", "pq", "/", "2", ")", "*", "Math", ".", "log", "(", "pq", "/", "(", "2", "*", "Math", ".", "sqrt", "(", "p", "[", "i", "]", "*", "q", "[", "i", "]", ")", ")", ")", ";", "}", "}", "return", "r", ";", "}" ]
Gets the Taneja divergence. @param p P vector. @param q Q vector. @return The Taneja divergence between p and q.
[ "Gets", "the", "Taneja", "divergence", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L889-L898
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/distance/Distance.java
Distance.TopsoeDivergence
public static double TopsoeDivergence(double[] p, double[] q) { double r = 0; for (int i = 0; i < p.length; i++) { if (p[i] != 0 && q[i] != 0) { double den = p[i] + q[i]; r += p[i] * Math.log(2 * p[i] / den) + q[i] * Math.log(2 * q[i] / den); } } return r; }
java
public static double TopsoeDivergence(double[] p, double[] q) { double r = 0; for (int i = 0; i < p.length; i++) { if (p[i] != 0 && q[i] != 0) { double den = p[i] + q[i]; r += p[i] * Math.log(2 * p[i] / den) + q[i] * Math.log(2 * q[i] / den); } } return r; }
[ "public", "static", "double", "TopsoeDivergence", "(", "double", "[", "]", "p", ",", "double", "[", "]", "q", ")", "{", "double", "r", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ".", "length", ";", "i", "++", ")", "{", "if", "(", "p", "[", "i", "]", "!=", "0", "&&", "q", "[", "i", "]", "!=", "0", ")", "{", "double", "den", "=", "p", "[", "i", "]", "+", "q", "[", "i", "]", ";", "r", "+=", "p", "[", "i", "]", "*", "Math", ".", "log", "(", "2", "*", "p", "[", "i", "]", "/", "den", ")", "+", "q", "[", "i", "]", "*", "Math", ".", "log", "(", "2", "*", "q", "[", "i", "]", "/", "den", ")", ";", "}", "}", "return", "r", ";", "}" ]
Gets the Topsoe divergence. @param p P vector. @param q Q vector. @return The Topsoe divergence between p and q.
[ "Gets", "the", "Topsoe", "divergence", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L907-L916
train
Harium/keel
src/main/java/jdt/triangulation/Triangle.java
Triangle.contains
public boolean contains(Vector3 p) { boolean ans = false; if(this.halfplane || p== null) return false; if (isCorner(p)) { return true; } PointLinePosition a12 = PointLineTest.pointLineTest(a,b,p); PointLinePosition a23 = PointLineTest.pointLineTest(b,c,p); PointLinePosition a31 = PointLineTest.pointLineTest(c,a,p); if ((a12 == PointLinePosition.LEFT && a23 == PointLinePosition.LEFT && a31 == PointLinePosition.LEFT ) || (a12 == PointLinePosition.RIGHT && a23 == PointLinePosition.RIGHT && a31 == PointLinePosition.RIGHT ) || (a12 == PointLinePosition.ON_SEGMENT ||a23 == PointLinePosition.ON_SEGMENT || a31 == PointLinePosition.ON_SEGMENT)) { ans = true; } return ans; }
java
public boolean contains(Vector3 p) { boolean ans = false; if(this.halfplane || p== null) return false; if (isCorner(p)) { return true; } PointLinePosition a12 = PointLineTest.pointLineTest(a,b,p); PointLinePosition a23 = PointLineTest.pointLineTest(b,c,p); PointLinePosition a31 = PointLineTest.pointLineTest(c,a,p); if ((a12 == PointLinePosition.LEFT && a23 == PointLinePosition.LEFT && a31 == PointLinePosition.LEFT ) || (a12 == PointLinePosition.RIGHT && a23 == PointLinePosition.RIGHT && a31 == PointLinePosition.RIGHT ) || (a12 == PointLinePosition.ON_SEGMENT ||a23 == PointLinePosition.ON_SEGMENT || a31 == PointLinePosition.ON_SEGMENT)) { ans = true; } return ans; }
[ "public", "boolean", "contains", "(", "Vector3", "p", ")", "{", "boolean", "ans", "=", "false", ";", "if", "(", "this", ".", "halfplane", "||", "p", "==", "null", ")", "return", "false", ";", "if", "(", "isCorner", "(", "p", ")", ")", "{", "return", "true", ";", "}", "PointLinePosition", "a12", "=", "PointLineTest", ".", "pointLineTest", "(", "a", ",", "b", ",", "p", ")", ";", "PointLinePosition", "a23", "=", "PointLineTest", ".", "pointLineTest", "(", "b", ",", "c", ",", "p", ")", ";", "PointLinePosition", "a31", "=", "PointLineTest", ".", "pointLineTest", "(", "c", ",", "a", ",", "p", ")", ";", "if", "(", "(", "a12", "==", "PointLinePosition", ".", "LEFT", "&&", "a23", "==", "PointLinePosition", ".", "LEFT", "&&", "a31", "==", "PointLinePosition", ".", "LEFT", ")", "||", "(", "a12", "==", "PointLinePosition", ".", "RIGHT", "&&", "a23", "==", "PointLinePosition", ".", "RIGHT", "&&", "a31", "==", "PointLinePosition", ".", "RIGHT", ")", "||", "(", "a12", "==", "PointLinePosition", ".", "ON_SEGMENT", "||", "a23", "==", "PointLinePosition", ".", "ON_SEGMENT", "||", "a31", "==", "PointLinePosition", ".", "ON_SEGMENT", ")", ")", "{", "ans", "=", "true", ";", "}", "return", "ans", ";", "}" ]
determinates if this triangle contains the point p. @param p the query point @return true iff p is not null and is inside this triangle (Note: on boundary is considered inside!!).
[ "determinates", "if", "this", "triangle", "contains", "the", "point", "p", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/jdt/triangulation/Triangle.java#L226-L245
train
Harium/keel
src/main/java/jdt/triangulation/Triangle.java
Triangle.calcDet
public static float calcDet(Vector3 a ,Vector3 b, Vector3 c) { return (a.x*(b.y-c.y)) - (a.y*(b.x-c.x)) + (b.x*c.y-b.y*c.x); }
java
public static float calcDet(Vector3 a ,Vector3 b, Vector3 c) { return (a.x*(b.y-c.y)) - (a.y*(b.x-c.x)) + (b.x*c.y-b.y*c.x); }
[ "public", "static", "float", "calcDet", "(", "Vector3", "a", ",", "Vector3", "b", ",", "Vector3", "c", ")", "{", "return", "(", "a", ".", "x", "*", "(", "b", ".", "y", "-", "c", ".", "y", ")", ")", "-", "(", "a", ".", "y", "*", "(", "b", ".", "x", "-", "c", ".", "x", ")", ")", "+", "(", "b", ".", "x", "*", "c", ".", "y", "-", "b", ".", "y", "*", "c", ".", "x", ")", ";", "}" ]
checks if the triangle is not re-entrant
[ "checks", "if", "the", "triangle", "is", "not", "re", "-", "entrant" ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/jdt/triangulation/Triangle.java#L423-L425
train
Harium/keel
src/main/java/jdt/triangulation/Triangle.java
Triangle.sharedSegments
public int sharedSegments(Triangle t2) { int counter = 0; if(a.equals(t2.a)) { counter++; } if(a.equals(t2.b)) { counter++; } if(a.equals(t2.c)) { counter++; } if(b.equals(t2.a)) { counter++; } if(b.equals(t2.b)) { counter++; } if(b.equals(t2.c)) { counter++; } if(c.equals(t2.a)) { counter++; } if(c.equals(t2.b)) { counter++; } if(c.equals(t2.c)) { counter++; } return counter; }
java
public int sharedSegments(Triangle t2) { int counter = 0; if(a.equals(t2.a)) { counter++; } if(a.equals(t2.b)) { counter++; } if(a.equals(t2.c)) { counter++; } if(b.equals(t2.a)) { counter++; } if(b.equals(t2.b)) { counter++; } if(b.equals(t2.c)) { counter++; } if(c.equals(t2.a)) { counter++; } if(c.equals(t2.b)) { counter++; } if(c.equals(t2.c)) { counter++; } return counter; }
[ "public", "int", "sharedSegments", "(", "Triangle", "t2", ")", "{", "int", "counter", "=", "0", ";", "if", "(", "a", ".", "equals", "(", "t2", ".", "a", ")", ")", "{", "counter", "++", ";", "}", "if", "(", "a", ".", "equals", "(", "t2", ".", "b", ")", ")", "{", "counter", "++", ";", "}", "if", "(", "a", ".", "equals", "(", "t2", ".", "c", ")", ")", "{", "counter", "++", ";", "}", "if", "(", "b", ".", "equals", "(", "t2", ".", "a", ")", ")", "{", "counter", "++", ";", "}", "if", "(", "b", ".", "equals", "(", "t2", ".", "b", ")", ")", "{", "counter", "++", ";", "}", "if", "(", "b", ".", "equals", "(", "t2", ".", "c", ")", ")", "{", "counter", "++", ";", "}", "if", "(", "c", ".", "equals", "(", "t2", ".", "a", ")", ")", "{", "counter", "++", ";", "}", "if", "(", "c", ".", "equals", "(", "t2", ".", "b", ")", ")", "{", "counter", "++", ";", "}", "if", "(", "c", ".", "equals", "(", "t2", ".", "c", ")", ")", "{", "counter", "++", ";", "}", "return", "counter", ";", "}" ]
checks if the 2 triangles shares a segment @author Doron Ganel & Eyal Roth(2009) @param t2 - a second triangle @return boolean
[ "checks", "if", "the", "2", "triangles", "shares", "a", "segment" ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/jdt/triangulation/Triangle.java#L447-L479
train
Harium/keel
src/main/java/com/harium/keel/effect/BinaryErosion.java
BinaryErosion.apply
@Override public ImageSource apply(ImageSource source) { if (radius != 0) { if (source.isGrayscale()) { return applyGrayscale(source, radius); } else { return applyRGB(source, radius); } } else { if (source.isGrayscale()) { return applyGrayscale(source, kernel); } else { return applyRGB(source, kernel); } } }
java
@Override public ImageSource apply(ImageSource source) { if (radius != 0) { if (source.isGrayscale()) { return applyGrayscale(source, radius); } else { return applyRGB(source, radius); } } else { if (source.isGrayscale()) { return applyGrayscale(source, kernel); } else { return applyRGB(source, kernel); } } }
[ "@", "Override", "public", "ImageSource", "apply", "(", "ImageSource", "source", ")", "{", "if", "(", "radius", "!=", "0", ")", "{", "if", "(", "source", ".", "isGrayscale", "(", ")", ")", "{", "return", "applyGrayscale", "(", "source", ",", "radius", ")", ";", "}", "else", "{", "return", "applyRGB", "(", "source", ",", "radius", ")", ";", "}", "}", "else", "{", "if", "(", "source", ".", "isGrayscale", "(", ")", ")", "{", "return", "applyGrayscale", "(", "source", ",", "kernel", ")", ";", "}", "else", "{", "return", "applyRGB", "(", "source", ",", "kernel", ")", ";", "}", "}", "}" ]
Apply filter to an image. @param source FastBitmap
[ "Apply", "filter", "to", "an", "image", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/effect/BinaryErosion.java#L74-L89
train
artikcloud/artikcloud-java
src/main/java/cloud/artik/client/ApiClient.java
ApiClient.handleResponse
public <T> T handleResponse(Response response, Type returnType) throws ApiException { if (response.isSuccessful()) { if (returnType == null || response.code() == 204) { // returning null if the returnType is not defined, // or the status code is 204 (No Content) return null; } else { return deserialize(response, returnType); } } else { String respBody = null; if (response.body() != null) { try { respBody = response.body().string(); } catch (IOException e) { throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); } } throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); } }
java
public <T> T handleResponse(Response response, Type returnType) throws ApiException { if (response.isSuccessful()) { if (returnType == null || response.code() == 204) { // returning null if the returnType is not defined, // or the status code is 204 (No Content) return null; } else { return deserialize(response, returnType); } } else { String respBody = null; if (response.body() != null) { try { respBody = response.body().string(); } catch (IOException e) { throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); } } throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); } }
[ "public", "<", "T", ">", "T", "handleResponse", "(", "Response", "response", ",", "Type", "returnType", ")", "throws", "ApiException", "{", "if", "(", "response", ".", "isSuccessful", "(", ")", ")", "{", "if", "(", "returnType", "==", "null", "||", "response", ".", "code", "(", ")", "==", "204", ")", "{", "// returning null if the returnType is not defined,", "// or the status code is 204 (No Content)", "return", "null", ";", "}", "else", "{", "return", "deserialize", "(", "response", ",", "returnType", ")", ";", "}", "}", "else", "{", "String", "respBody", "=", "null", ";", "if", "(", "response", ".", "body", "(", ")", "!=", "null", ")", "{", "try", "{", "respBody", "=", "response", ".", "body", "(", ")", ".", "string", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "ApiException", "(", "response", ".", "message", "(", ")", ",", "e", ",", "response", ".", "code", "(", ")", ",", "response", ".", "headers", "(", ")", ".", "toMultimap", "(", ")", ")", ";", "}", "}", "throw", "new", "ApiException", "(", "response", ".", "message", "(", ")", ",", "response", ".", "code", "(", ")", ",", "response", ".", "headers", "(", ")", ".", "toMultimap", "(", ")", ",", "respBody", ")", ";", "}", "}" ]
Handle the given response, return the deserialized object when the response is successful. @param <T> Type @param response Response @param returnType Return type @throws ApiException If the response has a unsuccessful status code or fail to deserialize the response body @return Type
[ "Handle", "the", "given", "response", "return", "the", "deserialized", "object", "when", "the", "response", "is", "successful", "." ]
412f447573e7796ab4f685c0bdd5eb76185a365c
https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/client/ApiClient.java#L1029-L1049
train
vnesek/nmote-iim4j
src/main/java/com/nmote/iim4j/IIMFile.java
IIMFile.add
public void add(int ds, Object value) throws SerializationException, InvalidDataSetException { if (value == null) { return; } DataSetInfo dsi = dsiFactory.create(ds); byte[] data = dsi.getSerializer().serialize(value, activeSerializationContext); DataSet dataSet = new DefaultDataSet(dsi, data); dataSets.add(dataSet); }
java
public void add(int ds, Object value) throws SerializationException, InvalidDataSetException { if (value == null) { return; } DataSetInfo dsi = dsiFactory.create(ds); byte[] data = dsi.getSerializer().serialize(value, activeSerializationContext); DataSet dataSet = new DefaultDataSet(dsi, data); dataSets.add(dataSet); }
[ "public", "void", "add", "(", "int", "ds", ",", "Object", "value", ")", "throws", "SerializationException", ",", "InvalidDataSetException", "{", "if", "(", "value", "==", "null", ")", "{", "return", ";", "}", "DataSetInfo", "dsi", "=", "dsiFactory", ".", "create", "(", "ds", ")", ";", "byte", "[", "]", "data", "=", "dsi", ".", "getSerializer", "(", ")", ".", "serialize", "(", "value", ",", "activeSerializationContext", ")", ";", "DataSet", "dataSet", "=", "new", "DefaultDataSet", "(", "dsi", ",", "data", ")", ";", "dataSets", ".", "add", "(", "dataSet", ")", ";", "}" ]
Adds a data set to IIM file. @param ds data set id (see constants in IIM class) @param value data set value. Null values are silently ignored. @throws SerializationException if value can't be serialized by data set's serializer @throws InvalidDataSetException if data set isn't defined
[ "Adds", "a", "data", "set", "to", "IIM", "file", "." ]
ec55b02fc644cd722e93051ac0bdb96b00cb42a8
https://github.com/vnesek/nmote-iim4j/blob/ec55b02fc644cd722e93051ac0bdb96b00cb42a8/src/main/java/com/nmote/iim4j/IIMFile.java#L79-L88
train
vnesek/nmote-iim4j
src/main/java/com/nmote/iim4j/IIMFile.java
IIMFile.addDateTimeHelper
public void addDateTimeHelper(int ds, Date date) throws SerializationException, InvalidDataSetException { if (date == null) { return; } DataSetInfo dsi = dsiFactory.create(ds); SimpleDateFormat df = new SimpleDateFormat(dsi.getSerializer().toString()); String value = df.format(date); byte[] data = dsi.getSerializer().serialize(value, activeSerializationContext); DataSet dataSet = new DefaultDataSet(dsi, data); add(dataSet); }
java
public void addDateTimeHelper(int ds, Date date) throws SerializationException, InvalidDataSetException { if (date == null) { return; } DataSetInfo dsi = dsiFactory.create(ds); SimpleDateFormat df = new SimpleDateFormat(dsi.getSerializer().toString()); String value = df.format(date); byte[] data = dsi.getSerializer().serialize(value, activeSerializationContext); DataSet dataSet = new DefaultDataSet(dsi, data); add(dataSet); }
[ "public", "void", "addDateTimeHelper", "(", "int", "ds", ",", "Date", "date", ")", "throws", "SerializationException", ",", "InvalidDataSetException", "{", "if", "(", "date", "==", "null", ")", "{", "return", ";", "}", "DataSetInfo", "dsi", "=", "dsiFactory", ".", "create", "(", "ds", ")", ";", "SimpleDateFormat", "df", "=", "new", "SimpleDateFormat", "(", "dsi", ".", "getSerializer", "(", ")", ".", "toString", "(", ")", ")", ";", "String", "value", "=", "df", ".", "format", "(", "date", ")", ";", "byte", "[", "]", "data", "=", "dsi", ".", "getSerializer", "(", ")", ".", "serialize", "(", "value", ",", "activeSerializationContext", ")", ";", "DataSet", "dataSet", "=", "new", "DefaultDataSet", "(", "dsi", ",", "data", ")", ";", "add", "(", "dataSet", ")", ";", "}" ]
Adds a data set with date-time value to IIM file. @param ds data set id (see constants in IIM class) @param date date to set. Null values are silently ignored. @throws SerializationException if value can't be serialized by data set's serializer @throws InvalidDataSetException if data set isn't defined
[ "Adds", "a", "data", "set", "with", "date", "-", "time", "value", "to", "IIM", "file", "." ]
ec55b02fc644cd722e93051ac0bdb96b00cb42a8
https://github.com/vnesek/nmote-iim4j/blob/ec55b02fc644cd722e93051ac0bdb96b00cb42a8/src/main/java/com/nmote/iim4j/IIMFile.java#L102-L114
train
vnesek/nmote-iim4j
src/main/java/com/nmote/iim4j/IIMFile.java
IIMFile.get
public Object get(int dataSet) throws SerializationException { Object result = null; for (Iterator<DataSet> i = dataSets.iterator(); i.hasNext();) { DataSet ds = i.next(); DataSetInfo info = ds.getInfo(); if (info.getDataSetNumber() == dataSet) { result = getData(ds); break; } } return result; }
java
public Object get(int dataSet) throws SerializationException { Object result = null; for (Iterator<DataSet> i = dataSets.iterator(); i.hasNext();) { DataSet ds = i.next(); DataSetInfo info = ds.getInfo(); if (info.getDataSetNumber() == dataSet) { result = getData(ds); break; } } return result; }
[ "public", "Object", "get", "(", "int", "dataSet", ")", "throws", "SerializationException", "{", "Object", "result", "=", "null", ";", "for", "(", "Iterator", "<", "DataSet", ">", "i", "=", "dataSets", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "DataSet", "ds", "=", "i", ".", "next", "(", ")", ";", "DataSetInfo", "info", "=", "ds", ".", "getInfo", "(", ")", ";", "if", "(", "info", ".", "getDataSetNumber", "(", ")", "==", "dataSet", ")", "{", "result", "=", "getData", "(", "ds", ")", ";", "break", ";", "}", "}", "return", "result", ";", "}" ]
Gets a first data set value. @param dataSet IIM record and dataset code (See constants in {@link IIM}) @return data set value @throws SerializationException if value can't be deserialized from binary representation
[ "Gets", "a", "first", "data", "set", "value", "." ]
ec55b02fc644cd722e93051ac0bdb96b00cb42a8
https://github.com/vnesek/nmote-iim4j/blob/ec55b02fc644cd722e93051ac0bdb96b00cb42a8/src/main/java/com/nmote/iim4j/IIMFile.java#L148-L159
train
vnesek/nmote-iim4j
src/main/java/com/nmote/iim4j/IIMFile.java
IIMFile.getAll
public List<Object> getAll(int dataSet) throws SerializationException { List<Object> result = new ArrayList<Object>(); for (Iterator<DataSet> i = dataSets.iterator(); i.hasNext();) { DataSet ds = i.next(); DataSetInfo info = ds.getInfo(); if (info.getDataSetNumber() == dataSet) { result.add(getData(ds)); } } return result; }
java
public List<Object> getAll(int dataSet) throws SerializationException { List<Object> result = new ArrayList<Object>(); for (Iterator<DataSet> i = dataSets.iterator(); i.hasNext();) { DataSet ds = i.next(); DataSetInfo info = ds.getInfo(); if (info.getDataSetNumber() == dataSet) { result.add(getData(ds)); } } return result; }
[ "public", "List", "<", "Object", ">", "getAll", "(", "int", "dataSet", ")", "throws", "SerializationException", "{", "List", "<", "Object", ">", "result", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "for", "(", "Iterator", "<", "DataSet", ">", "i", "=", "dataSets", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "DataSet", "ds", "=", "i", ".", "next", "(", ")", ";", "DataSetInfo", "info", "=", "ds", ".", "getInfo", "(", ")", ";", "if", "(", "info", ".", "getDataSetNumber", "(", ")", "==", "dataSet", ")", "{", "result", ".", "add", "(", "getData", "(", "ds", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Gets all data set values. @param dataSet IIM record and dataset code (See constants in {@link IIM}) @return data set value @throws SerializationException if value can't be deserialized from binary representation
[ "Gets", "all", "data", "set", "values", "." ]
ec55b02fc644cd722e93051ac0bdb96b00cb42a8
https://github.com/vnesek/nmote-iim4j/blob/ec55b02fc644cd722e93051ac0bdb96b00cb42a8/src/main/java/com/nmote/iim4j/IIMFile.java#L170-L180
train
vnesek/nmote-iim4j
src/main/java/com/nmote/iim4j/IIMFile.java
IIMFile.readFrom
public void readFrom(IIMReader reader, int recover) throws IOException, InvalidDataSetException { final boolean doLog = log != null; for (;;) { try { DataSet ds = reader.read(); if (ds == null) { break; } if (doLog) { log.debug("Read data set " + ds); } DataSetInfo info = ds.getInfo(); Serializer s = info.getSerializer(); if (s != null) { if (info.getDataSetNumber() == IIM.DS(1, 90)) { setCharacterSet((String) s.deserialize(ds.getData(), activeSerializationContext)); } } dataSets.add(ds); if (stopAfter9_10 && info.getDataSetNumber() == IIM.DS(9, 10)) break; } catch (IIMFormatException e) { if (recoverFromIIMFormat && recover-- > 0) { boolean r = reader.recover(); if (doLog) { log.debug(r ? "Recoved from " + e : "Failed to recover from " + e); } if (!r) break; } else { throw e; } } catch (UnsupportedDataSetException e) { if (recoverFromUnsupportedDataSet && recover-- > 0) { boolean r = reader.recover(); if (doLog) { log.debug(r ? "Recoved from " + e : "Failed to recover from " + e); } if (!r) break; } else { throw e; } } catch (InvalidDataSetException e) { if (recoverFromInvalidDataSet && recover-- > 0) { boolean r = reader.recover(); if (doLog) { log.debug(r ? "Recoved from " + e : "Failed to recover from " + e); } if (!r) break; } else { throw e; } } catch (IOException e) { if (recover-- > 0 && !dataSets.isEmpty()) { if (doLog) { log.error("IOException while reading, however some data sets where recovered, " + e); } return; } else { throw e; } } } }
java
public void readFrom(IIMReader reader, int recover) throws IOException, InvalidDataSetException { final boolean doLog = log != null; for (;;) { try { DataSet ds = reader.read(); if (ds == null) { break; } if (doLog) { log.debug("Read data set " + ds); } DataSetInfo info = ds.getInfo(); Serializer s = info.getSerializer(); if (s != null) { if (info.getDataSetNumber() == IIM.DS(1, 90)) { setCharacterSet((String) s.deserialize(ds.getData(), activeSerializationContext)); } } dataSets.add(ds); if (stopAfter9_10 && info.getDataSetNumber() == IIM.DS(9, 10)) break; } catch (IIMFormatException e) { if (recoverFromIIMFormat && recover-- > 0) { boolean r = reader.recover(); if (doLog) { log.debug(r ? "Recoved from " + e : "Failed to recover from " + e); } if (!r) break; } else { throw e; } } catch (UnsupportedDataSetException e) { if (recoverFromUnsupportedDataSet && recover-- > 0) { boolean r = reader.recover(); if (doLog) { log.debug(r ? "Recoved from " + e : "Failed to recover from " + e); } if (!r) break; } else { throw e; } } catch (InvalidDataSetException e) { if (recoverFromInvalidDataSet && recover-- > 0) { boolean r = reader.recover(); if (doLog) { log.debug(r ? "Recoved from " + e : "Failed to recover from " + e); } if (!r) break; } else { throw e; } } catch (IOException e) { if (recover-- > 0 && !dataSets.isEmpty()) { if (doLog) { log.error("IOException while reading, however some data sets where recovered, " + e); } return; } else { throw e; } } } }
[ "public", "void", "readFrom", "(", "IIMReader", "reader", ",", "int", "recover", ")", "throws", "IOException", ",", "InvalidDataSetException", "{", "final", "boolean", "doLog", "=", "log", "!=", "null", ";", "for", "(", ";", ";", ")", "{", "try", "{", "DataSet", "ds", "=", "reader", ".", "read", "(", ")", ";", "if", "(", "ds", "==", "null", ")", "{", "break", ";", "}", "if", "(", "doLog", ")", "{", "log", ".", "debug", "(", "\"Read data set \"", "+", "ds", ")", ";", "}", "DataSetInfo", "info", "=", "ds", ".", "getInfo", "(", ")", ";", "Serializer", "s", "=", "info", ".", "getSerializer", "(", ")", ";", "if", "(", "s", "!=", "null", ")", "{", "if", "(", "info", ".", "getDataSetNumber", "(", ")", "==", "IIM", ".", "DS", "(", "1", ",", "90", ")", ")", "{", "setCharacterSet", "(", "(", "String", ")", "s", ".", "deserialize", "(", "ds", ".", "getData", "(", ")", ",", "activeSerializationContext", ")", ")", ";", "}", "}", "dataSets", ".", "add", "(", "ds", ")", ";", "if", "(", "stopAfter9_10", "&&", "info", ".", "getDataSetNumber", "(", ")", "==", "IIM", ".", "DS", "(", "9", ",", "10", ")", ")", "break", ";", "}", "catch", "(", "IIMFormatException", "e", ")", "{", "if", "(", "recoverFromIIMFormat", "&&", "recover", "--", ">", "0", ")", "{", "boolean", "r", "=", "reader", ".", "recover", "(", ")", ";", "if", "(", "doLog", ")", "{", "log", ".", "debug", "(", "r", "?", "\"Recoved from \"", "+", "e", ":", "\"Failed to recover from \"", "+", "e", ")", ";", "}", "if", "(", "!", "r", ")", "break", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "catch", "(", "UnsupportedDataSetException", "e", ")", "{", "if", "(", "recoverFromUnsupportedDataSet", "&&", "recover", "--", ">", "0", ")", "{", "boolean", "r", "=", "reader", ".", "recover", "(", ")", ";", "if", "(", "doLog", ")", "{", "log", ".", "debug", "(", "r", "?", "\"Recoved from \"", "+", "e", ":", "\"Failed to recover from \"", "+", "e", ")", ";", "}", "if", "(", "!", "r", ")", "break", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "catch", "(", "InvalidDataSetException", "e", ")", "{", "if", "(", "recoverFromInvalidDataSet", "&&", "recover", "--", ">", "0", ")", "{", "boolean", "r", "=", "reader", ".", "recover", "(", ")", ";", "if", "(", "doLog", ")", "{", "log", ".", "debug", "(", "r", "?", "\"Recoved from \"", "+", "e", ":", "\"Failed to recover from \"", "+", "e", ")", ";", "}", "if", "(", "!", "r", ")", "break", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "if", "(", "recover", "--", ">", "0", "&&", "!", "dataSets", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "doLog", ")", "{", "log", ".", "error", "(", "\"IOException while reading, however some data sets where recovered, \"", "+", "e", ")", ";", "}", "return", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "}", "}" ]
Reads data sets from a passed reader. @param reader data sets source @param recover max number of errors reading process will try to recover from. Set to 0 to fail immediately @throws IOException if reader can't read underlying stream @throws InvalidDataSetException if invalid/undefined data set is encountered
[ "Reads", "data", "sets", "from", "a", "passed", "reader", "." ]
ec55b02fc644cd722e93051ac0bdb96b00cb42a8
https://github.com/vnesek/nmote-iim4j/blob/ec55b02fc644cd722e93051ac0bdb96b00cb42a8/src/main/java/com/nmote/iim4j/IIMFile.java#L288-L357
train
vnesek/nmote-iim4j
src/main/java/com/nmote/iim4j/IIMFile.java
IIMFile.writeTo
public void writeTo(IIMWriter writer) throws IOException { final boolean doLog = log != null; for (Iterator<DataSet> i = dataSets.iterator(); i.hasNext();) { DataSet ds = i.next(); writer.write(ds); if (doLog) { log.debug("Wrote data set " + ds); } } }
java
public void writeTo(IIMWriter writer) throws IOException { final boolean doLog = log != null; for (Iterator<DataSet> i = dataSets.iterator(); i.hasNext();) { DataSet ds = i.next(); writer.write(ds); if (doLog) { log.debug("Wrote data set " + ds); } } }
[ "public", "void", "writeTo", "(", "IIMWriter", "writer", ")", "throws", "IOException", "{", "final", "boolean", "doLog", "=", "log", "!=", "null", ";", "for", "(", "Iterator", "<", "DataSet", ">", "i", "=", "dataSets", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "DataSet", "ds", "=", "i", ".", "next", "(", ")", ";", "writer", ".", "write", "(", "ds", ")", ";", "if", "(", "doLog", ")", "{", "log", ".", "debug", "(", "\"Wrote data set \"", "+", "ds", ")", ";", "}", "}", "}" ]
Writes this IIMFile to writer. @param writer writer to write to @throws IOException if file can't be written to
[ "Writes", "this", "IIMFile", "to", "writer", "." ]
ec55b02fc644cd722e93051ac0bdb96b00cb42a8
https://github.com/vnesek/nmote-iim4j/blob/ec55b02fc644cd722e93051ac0bdb96b00cb42a8/src/main/java/com/nmote/iim4j/IIMFile.java#L469-L478
train
vnesek/nmote-iim4j
src/main/java/com/nmote/iim4j/IIMFile.java
IIMFile.validate
public Set<ConstraintViolation> validate(DataSetInfo info) { Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>(); try { if (info.isMandatory() && get(info.getDataSetNumber()) == null) { errors.add(new ConstraintViolation(info, ConstraintViolation.MANDATORY_MISSING)); } if (!info.isRepeatable() && getAll(info.getDataSetNumber()).size() > 1) { errors.add(new ConstraintViolation(info, ConstraintViolation.REPEATABLE_REPEATED)); } } catch (SerializationException e) { errors.add(new ConstraintViolation(info, ConstraintViolation.INVALID_VALUE)); } return errors; }
java
public Set<ConstraintViolation> validate(DataSetInfo info) { Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>(); try { if (info.isMandatory() && get(info.getDataSetNumber()) == null) { errors.add(new ConstraintViolation(info, ConstraintViolation.MANDATORY_MISSING)); } if (!info.isRepeatable() && getAll(info.getDataSetNumber()).size() > 1) { errors.add(new ConstraintViolation(info, ConstraintViolation.REPEATABLE_REPEATED)); } } catch (SerializationException e) { errors.add(new ConstraintViolation(info, ConstraintViolation.INVALID_VALUE)); } return errors; }
[ "public", "Set", "<", "ConstraintViolation", ">", "validate", "(", "DataSetInfo", "info", ")", "{", "Set", "<", "ConstraintViolation", ">", "errors", "=", "new", "LinkedHashSet", "<", "ConstraintViolation", ">", "(", ")", ";", "try", "{", "if", "(", "info", ".", "isMandatory", "(", ")", "&&", "get", "(", "info", ".", "getDataSetNumber", "(", ")", ")", "==", "null", ")", "{", "errors", ".", "add", "(", "new", "ConstraintViolation", "(", "info", ",", "ConstraintViolation", ".", "MANDATORY_MISSING", ")", ")", ";", "}", "if", "(", "!", "info", ".", "isRepeatable", "(", ")", "&&", "getAll", "(", "info", ".", "getDataSetNumber", "(", ")", ")", ".", "size", "(", ")", ">", "1", ")", "{", "errors", ".", "add", "(", "new", "ConstraintViolation", "(", "info", ",", "ConstraintViolation", ".", "REPEATABLE_REPEATED", ")", ")", ";", "}", "}", "catch", "(", "SerializationException", "e", ")", "{", "errors", ".", "add", "(", "new", "ConstraintViolation", "(", "info", ",", "ConstraintViolation", ".", "INVALID_VALUE", ")", ")", ";", "}", "return", "errors", ";", "}" ]
Checks if data set is mandatory but missing or non repeatable but having multiple values in this IIM instance. @param info IIM data set to check @return list of constraint violations, empty set if data set is valid
[ "Checks", "if", "data", "set", "is", "mandatory", "but", "missing", "or", "non", "repeatable", "but", "having", "multiple", "values", "in", "this", "IIM", "instance", "." ]
ec55b02fc644cd722e93051ac0bdb96b00cb42a8
https://github.com/vnesek/nmote-iim4j/blob/ec55b02fc644cd722e93051ac0bdb96b00cb42a8/src/main/java/com/nmote/iim4j/IIMFile.java#L500-L513
train
vnesek/nmote-iim4j
src/main/java/com/nmote/iim4j/IIMFile.java
IIMFile.validate
public Set<ConstraintViolation> validate(int record) { Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>(); for (int ds = 0; ds < 250; ++ds) { try { DataSetInfo dataSetInfo = dsiFactory.create(IIM.DS(record, ds)); errors.addAll(validate(dataSetInfo)); } catch (InvalidDataSetException ignored) { // DataSetFactory doesn't know about this ds, so will skip it } } return errors; }
java
public Set<ConstraintViolation> validate(int record) { Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>(); for (int ds = 0; ds < 250; ++ds) { try { DataSetInfo dataSetInfo = dsiFactory.create(IIM.DS(record, ds)); errors.addAll(validate(dataSetInfo)); } catch (InvalidDataSetException ignored) { // DataSetFactory doesn't know about this ds, so will skip it } } return errors; }
[ "public", "Set", "<", "ConstraintViolation", ">", "validate", "(", "int", "record", ")", "{", "Set", "<", "ConstraintViolation", ">", "errors", "=", "new", "LinkedHashSet", "<", "ConstraintViolation", ">", "(", ")", ";", "for", "(", "int", "ds", "=", "0", ";", "ds", "<", "250", ";", "++", "ds", ")", "{", "try", "{", "DataSetInfo", "dataSetInfo", "=", "dsiFactory", ".", "create", "(", "IIM", ".", "DS", "(", "record", ",", "ds", ")", ")", ";", "errors", ".", "addAll", "(", "validate", "(", "dataSetInfo", ")", ")", ";", "}", "catch", "(", "InvalidDataSetException", "ignored", ")", "{", "// DataSetFactory doesn't know about this ds, so will skip it\r", "}", "}", "return", "errors", ";", "}" ]
Checks all data sets in a given record for constraint violations. @param record IIM record (1,2,3, ...) to check @return list of constraint violations, empty set if IIM file is valid
[ "Checks", "all", "data", "sets", "in", "a", "given", "record", "for", "constraint", "violations", "." ]
ec55b02fc644cd722e93051ac0bdb96b00cb42a8
https://github.com/vnesek/nmote-iim4j/blob/ec55b02fc644cd722e93051ac0bdb96b00cb42a8/src/main/java/com/nmote/iim4j/IIMFile.java#L523-L534
train
vnesek/nmote-iim4j
src/main/java/com/nmote/iim4j/IIMFile.java
IIMFile.validate
public Set<ConstraintViolation> validate() { Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>(); for (int record = 1; record <= 3; ++record) { errors.addAll(validate(record)); } return errors; }
java
public Set<ConstraintViolation> validate() { Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>(); for (int record = 1; record <= 3; ++record) { errors.addAll(validate(record)); } return errors; }
[ "public", "Set", "<", "ConstraintViolation", ">", "validate", "(", ")", "{", "Set", "<", "ConstraintViolation", ">", "errors", "=", "new", "LinkedHashSet", "<", "ConstraintViolation", ">", "(", ")", ";", "for", "(", "int", "record", "=", "1", ";", "record", "<=", "3", ";", "++", "record", ")", "{", "errors", ".", "addAll", "(", "validate", "(", "record", ")", ")", ";", "}", "return", "errors", ";", "}" ]
Checks all data sets in IIM records 1, 2 and 3 for constraint violations. @return list of constraint violations, empty set if IIM file is valid
[ "Checks", "all", "data", "sets", "in", "IIM", "records", "1", "2", "and", "3", "for", "constraint", "violations", "." ]
ec55b02fc644cd722e93051ac0bdb96b00cb42a8
https://github.com/vnesek/nmote-iim4j/blob/ec55b02fc644cd722e93051ac0bdb96b00cb42a8/src/main/java/com/nmote/iim4j/IIMFile.java#L541-L547
train
Harium/keel
src/main/java/jdt/triangulation/PointComparator.java
PointComparator.compare
public int compare(Vector3 o1, Vector3 o2) { int ans = 0; if (o1 != null && o2 != null) { Vector3 d1 = o1; Vector3 d2 = o2; if (d1.x > d2.x) return 1; if (d1.x < d2.x) return -1; // x1 == x2 if (d1.y > d2.y) return 1; if (d1.y < d2.y) return -1; } else { if (o1 == null && o2 == null) return 0; if (o1 == null && o2 != null) return 1; if (o1 != null && o2 == null) return -1; } return ans; }
java
public int compare(Vector3 o1, Vector3 o2) { int ans = 0; if (o1 != null && o2 != null) { Vector3 d1 = o1; Vector3 d2 = o2; if (d1.x > d2.x) return 1; if (d1.x < d2.x) return -1; // x1 == x2 if (d1.y > d2.y) return 1; if (d1.y < d2.y) return -1; } else { if (o1 == null && o2 == null) return 0; if (o1 == null && o2 != null) return 1; if (o1 != null && o2 == null) return -1; } return ans; }
[ "public", "int", "compare", "(", "Vector3", "o1", ",", "Vector3", "o2", ")", "{", "int", "ans", "=", "0", ";", "if", "(", "o1", "!=", "null", "&&", "o2", "!=", "null", ")", "{", "Vector3", "d1", "=", "o1", ";", "Vector3", "d2", "=", "o2", ";", "if", "(", "d1", ".", "x", ">", "d2", ".", "x", ")", "return", "1", ";", "if", "(", "d1", ".", "x", "<", "d2", ".", "x", ")", "return", "-", "1", ";", "// x1 == x2", "if", "(", "d1", ".", "y", ">", "d2", ".", "y", ")", "return", "1", ";", "if", "(", "d1", ".", "y", "<", "d2", ".", "y", ")", "return", "-", "1", ";", "}", "else", "{", "if", "(", "o1", "==", "null", "&&", "o2", "==", "null", ")", "return", "0", ";", "if", "(", "o1", "==", "null", "&&", "o2", "!=", "null", ")", "return", "1", ";", "if", "(", "o1", "!=", "null", "&&", "o2", "==", "null", ")", "return", "-", "1", ";", "}", "return", "ans", ";", "}" ]
compare between two points.
[ "compare", "between", "two", "points", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/jdt/triangulation/PointComparator.java#L15-L41
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/random/Random.java
Random.nextDouble
public double nextDouble(double lo, double hi) { if (lo < 0) { if (nextInt(2) == 0) return -nextDouble(0, -lo); else return nextDouble(0, hi); } else { return (lo + (hi - lo) * nextDouble()); } }
java
public double nextDouble(double lo, double hi) { if (lo < 0) { if (nextInt(2) == 0) return -nextDouble(0, -lo); else return nextDouble(0, hi); } else { return (lo + (hi - lo) * nextDouble()); } }
[ "public", "double", "nextDouble", "(", "double", "lo", ",", "double", "hi", ")", "{", "if", "(", "lo", "<", "0", ")", "{", "if", "(", "nextInt", "(", "2", ")", "==", "0", ")", "return", "-", "nextDouble", "(", "0", ",", "-", "lo", ")", ";", "else", "return", "nextDouble", "(", "0", ",", "hi", ")", ";", "}", "else", "{", "return", "(", "lo", "+", "(", "hi", "-", "lo", ")", "*", "nextDouble", "(", ")", ")", ";", "}", "}" ]
Generate a uniform random number in the range [lo, hi) @param lo lower limit of range @param hi upper limit of range @return a uniform random real in the range [lo, hi)
[ "Generate", "a", "uniform", "random", "number", "in", "the", "range", "[", "lo", "hi", ")" ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/random/Random.java#L92-L101
train
artikcloud/artikcloud-java
src/main/java/cloud/artik/api/TagsApi.java
TagsApi.getTagCategoriesWithHttpInfo
public ApiResponse<TagsEnvelope> getTagCategoriesWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = getTagCategoriesValidateBeforeCall(null, null); Type localVarReturnType = new TypeToken<TagsEnvelope>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
java
public ApiResponse<TagsEnvelope> getTagCategoriesWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = getTagCategoriesValidateBeforeCall(null, null); Type localVarReturnType = new TypeToken<TagsEnvelope>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
[ "public", "ApiResponse", "<", "TagsEnvelope", ">", "getTagCategoriesWithHttpInfo", "(", ")", "throws", "ApiException", "{", "com", ".", "squareup", ".", "okhttp", ".", "Call", "call", "=", "getTagCategoriesValidateBeforeCall", "(", "null", ",", "null", ")", ";", "Type", "localVarReturnType", "=", "new", "TypeToken", "<", "TagsEnvelope", ">", "(", ")", "{", "}", ".", "getType", "(", ")", ";", "return", "apiClient", ".", "execute", "(", "call", ",", "localVarReturnType", ")", ";", "}" ]
Get all categories Get all tags marked as categories @return ApiResponse&lt;TagsEnvelope&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
[ "Get", "all", "categories", "Get", "all", "tags", "marked", "as", "categories" ]
412f447573e7796ab4f685c0bdd5eb76185a365c
https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/TagsApi.java#L128-L132
train
artikcloud/artikcloud-java
src/main/java/cloud/artik/api/RulesApi.java
RulesApi.getRule
public RuleEnvelope getRule(String ruleId) throws ApiException { ApiResponse<RuleEnvelope> resp = getRuleWithHttpInfo(ruleId); return resp.getData(); }
java
public RuleEnvelope getRule(String ruleId) throws ApiException { ApiResponse<RuleEnvelope> resp = getRuleWithHttpInfo(ruleId); return resp.getData(); }
[ "public", "RuleEnvelope", "getRule", "(", "String", "ruleId", ")", "throws", "ApiException", "{", "ApiResponse", "<", "RuleEnvelope", ">", "resp", "=", "getRuleWithHttpInfo", "(", "ruleId", ")", ";", "return", "resp", ".", "getData", "(", ")", ";", "}" ]
Get Rule Get a rule using the Rule ID @param ruleId Rule ID. (required) @return RuleEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
[ "Get", "Rule", "Get", "a", "rule", "using", "the", "Rule", "ID" ]
412f447573e7796ab4f685c0bdd5eb76185a365c
https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/RulesApi.java#L373-L376
train
Harium/keel
src/main/java/com/harium/keel/filter/search/flood/FloodFillSearch.java
FloodFillSearch.addNeighbor
protected void addNeighbor(Queue<ColorPoint> queue, int px, int py, int color, Feature component) { if (!inBoundary(px, py, component)) { return; } if (!mask.isTouched(px, py)) { queue.add(new ColorPoint(px, py, color)); } }
java
protected void addNeighbor(Queue<ColorPoint> queue, int px, int py, int color, Feature component) { if (!inBoundary(px, py, component)) { return; } if (!mask.isTouched(px, py)) { queue.add(new ColorPoint(px, py, color)); } }
[ "protected", "void", "addNeighbor", "(", "Queue", "<", "ColorPoint", ">", "queue", ",", "int", "px", ",", "int", "py", ",", "int", "color", ",", "Feature", "component", ")", "{", "if", "(", "!", "inBoundary", "(", "px", ",", "py", ",", "component", ")", ")", "{", "return", ";", "}", "if", "(", "!", "mask", ".", "isTouched", "(", "px", ",", "py", ")", ")", "{", "queue", ".", "add", "(", "new", "ColorPoint", "(", "px", ",", "py", ",", "color", ")", ")", ";", "}", "}" ]
May have to be changed to let multiple touch
[ "May", "have", "to", "be", "changed", "to", "let", "multiple", "touch" ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/filter/search/flood/FloodFillSearch.java#L137-L145
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Gaussian.java
Gaussian.Function1D
public double Function1D(double x) { return Math.exp(x * x / (-2 * sqrSigma)) / (Math.sqrt(2 * Math.PI) * sigma); }
java
public double Function1D(double x) { return Math.exp(x * x / (-2 * sqrSigma)) / (Math.sqrt(2 * Math.PI) * sigma); }
[ "public", "double", "Function1D", "(", "double", "x", ")", "{", "return", "Math", ".", "exp", "(", "x", "*", "x", "/", "(", "-", "2", "*", "sqrSigma", ")", ")", "/", "(", "Math", ".", "sqrt", "(", "2", "*", "Math", ".", "PI", ")", "*", "sigma", ")", ";", "}" ]
1-D Gaussian function. @param x value. @return Function's value at point x.
[ "1", "-", "D", "Gaussian", "function", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Gaussian.java#L80-L82
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Gaussian.java
Gaussian.Function2D
public double Function2D(double x, double y) { return Math.exp(-(x * x + y * y) / (2 * sqrSigma)) / (2 * Math.PI * sqrSigma); }
java
public double Function2D(double x, double y) { return Math.exp(-(x * x + y * y) / (2 * sqrSigma)) / (2 * Math.PI * sqrSigma); }
[ "public", "double", "Function2D", "(", "double", "x", ",", "double", "y", ")", "{", "return", "Math", ".", "exp", "(", "-", "(", "x", "*", "x", "+", "y", "*", "y", ")", "/", "(", "2", "*", "sqrSigma", ")", ")", "/", "(", "2", "*", "Math", ".", "PI", "*", "sqrSigma", ")", ";", "}" ]
2-D Gaussian function. @param x value. @param y value. @return Function's value at point (x,y).
[ "2", "-", "D", "Gaussian", "function", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Gaussian.java#L91-L93
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Gaussian.java
Gaussian.Kernel1D
public double[] Kernel1D(int size) { if (((size % 2) == 0) || (size < 3) || (size > 101)) { try { throw new Exception("Wrong size"); } catch (Exception e) { e.printStackTrace(); } } int r = size / 2; // kernel double[] kernel = new double[size]; // compute kernel for (int x = -r, i = 0; i < size; x++, i++) { kernel[i] = Function1D(x); } return kernel; }
java
public double[] Kernel1D(int size) { if (((size % 2) == 0) || (size < 3) || (size > 101)) { try { throw new Exception("Wrong size"); } catch (Exception e) { e.printStackTrace(); } } int r = size / 2; // kernel double[] kernel = new double[size]; // compute kernel for (int x = -r, i = 0; i < size; x++, i++) { kernel[i] = Function1D(x); } return kernel; }
[ "public", "double", "[", "]", "Kernel1D", "(", "int", "size", ")", "{", "if", "(", "(", "(", "size", "%", "2", ")", "==", "0", ")", "||", "(", "size", "<", "3", ")", "||", "(", "size", ">", "101", ")", ")", "{", "try", "{", "throw", "new", "Exception", "(", "\"Wrong size\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "int", "r", "=", "size", "/", "2", ";", "// kernel", "double", "[", "]", "kernel", "=", "new", "double", "[", "size", "]", ";", "// compute kernel", "for", "(", "int", "x", "=", "-", "r", ",", "i", "=", "0", ";", "i", "<", "size", ";", "x", "++", ",", "i", "++", ")", "{", "kernel", "[", "i", "]", "=", "Function1D", "(", "x", ")", ";", "}", "return", "kernel", ";", "}" ]
1-D Gaussian kernel. @param size Kernel size (should be odd), [3, 101]. @return Returns 1-D Gaussian kernel of the specified size.
[ "1", "-", "D", "Gaussian", "kernel", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Gaussian.java#L101-L119
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/function/Gaussian.java
Gaussian.Kernel2D
public double[][] Kernel2D(int size) { if (((size % 2) == 0) || (size < 3) || (size > 101)) { try { throw new Exception("Wrong size"); } catch (Exception e) { e.printStackTrace(); } } int r = size / 2; double[][] kernel = new double[size][size]; // compute kernel double sum = 0; for (int y = -r, i = 0; i < size; y++, i++) { for (int x = -r, j = 0; j < size; x++, j++) { kernel[i][j] = Function2D(x, y); sum += kernel[i][j]; } } for (int i = 0; i < kernel.length; i++) { for (int j = 0; j < kernel[0].length; j++) { kernel[i][j] /= sum; } } return kernel; }
java
public double[][] Kernel2D(int size) { if (((size % 2) == 0) || (size < 3) || (size > 101)) { try { throw new Exception("Wrong size"); } catch (Exception e) { e.printStackTrace(); } } int r = size / 2; double[][] kernel = new double[size][size]; // compute kernel double sum = 0; for (int y = -r, i = 0; i < size; y++, i++) { for (int x = -r, j = 0; j < size; x++, j++) { kernel[i][j] = Function2D(x, y); sum += kernel[i][j]; } } for (int i = 0; i < kernel.length; i++) { for (int j = 0; j < kernel[0].length; j++) { kernel[i][j] /= sum; } } return kernel; }
[ "public", "double", "[", "]", "[", "]", "Kernel2D", "(", "int", "size", ")", "{", "if", "(", "(", "(", "size", "%", "2", ")", "==", "0", ")", "||", "(", "size", "<", "3", ")", "||", "(", "size", ">", "101", ")", ")", "{", "try", "{", "throw", "new", "Exception", "(", "\"Wrong size\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "int", "r", "=", "size", "/", "2", ";", "double", "[", "]", "[", "]", "kernel", "=", "new", "double", "[", "size", "]", "[", "size", "]", ";", "// compute kernel", "double", "sum", "=", "0", ";", "for", "(", "int", "y", "=", "-", "r", ",", "i", "=", "0", ";", "i", "<", "size", ";", "y", "++", ",", "i", "++", ")", "{", "for", "(", "int", "x", "=", "-", "r", ",", "j", "=", "0", ";", "j", "<", "size", ";", "x", "++", ",", "j", "++", ")", "{", "kernel", "[", "i", "]", "[", "j", "]", "=", "Function2D", "(", "x", ",", "y", ")", ";", "sum", "+=", "kernel", "[", "i", "]", "[", "j", "]", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "kernel", ".", "length", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "kernel", "[", "0", "]", ".", "length", ";", "j", "++", ")", "{", "kernel", "[", "i", "]", "[", "j", "]", "/=", "sum", ";", "}", "}", "return", "kernel", ";", "}" ]
2-D Gaussian kernel. @param size Kernel size (should be odd), [3, 101]. @return Returns 2-D Gaussian kernel of specified size.
[ "2", "-", "D", "Gaussian", "kernel", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/function/Gaussian.java#L127-L155
train
Harium/keel
src/main/java/com/harium/keel/effect/ExtractBoundary.java
ExtractBoundary.process
public ArrayList<IntPoint> process(ImageSource fastBitmap) { //FastBitmap l = new FastBitmap(fastBitmap); if (points == null) { apply(fastBitmap); } int width = fastBitmap.getWidth(); int height = fastBitmap.getHeight(); points = new ArrayList<IntPoint>(); if (fastBitmap.isGrayscale()) { for (int x = 0; x < height; x++) { for (int y = 0; y < width; y++) { if (fastBitmap.getRGB(y, x) == 255) points.add(new IntPoint(y, x)); } } } else { for (int x = 0; x < height; x++) { for (int y = 0; y < width; y++) { // TODO Check for green and blue? if (fastBitmap.getR(y, x) == 255) points.add(new IntPoint(y, x)); } } } return points; }
java
public ArrayList<IntPoint> process(ImageSource fastBitmap) { //FastBitmap l = new FastBitmap(fastBitmap); if (points == null) { apply(fastBitmap); } int width = fastBitmap.getWidth(); int height = fastBitmap.getHeight(); points = new ArrayList<IntPoint>(); if (fastBitmap.isGrayscale()) { for (int x = 0; x < height; x++) { for (int y = 0; y < width; y++) { if (fastBitmap.getRGB(y, x) == 255) points.add(new IntPoint(y, x)); } } } else { for (int x = 0; x < height; x++) { for (int y = 0; y < width; y++) { // TODO Check for green and blue? if (fastBitmap.getR(y, x) == 255) points.add(new IntPoint(y, x)); } } } return points; }
[ "public", "ArrayList", "<", "IntPoint", ">", "process", "(", "ImageSource", "fastBitmap", ")", "{", "//FastBitmap l = new FastBitmap(fastBitmap);\r", "if", "(", "points", "==", "null", ")", "{", "apply", "(", "fastBitmap", ")", ";", "}", "int", "width", "=", "fastBitmap", ".", "getWidth", "(", ")", ";", "int", "height", "=", "fastBitmap", ".", "getHeight", "(", ")", ";", "points", "=", "new", "ArrayList", "<", "IntPoint", ">", "(", ")", ";", "if", "(", "fastBitmap", ".", "isGrayscale", "(", ")", ")", "{", "for", "(", "int", "x", "=", "0", ";", "x", "<", "height", ";", "x", "++", ")", "{", "for", "(", "int", "y", "=", "0", ";", "y", "<", "width", ";", "y", "++", ")", "{", "if", "(", "fastBitmap", ".", "getRGB", "(", "y", ",", "x", ")", "==", "255", ")", "points", ".", "add", "(", "new", "IntPoint", "(", "y", ",", "x", ")", ")", ";", "}", "}", "}", "else", "{", "for", "(", "int", "x", "=", "0", ";", "x", "<", "height", ";", "x", "++", ")", "{", "for", "(", "int", "y", "=", "0", ";", "y", "<", "width", ";", "y", "++", ")", "{", "// TODO Check for green and blue?\r", "if", "(", "fastBitmap", ".", "getR", "(", "y", ",", "x", ")", "==", "255", ")", "points", ".", "add", "(", "new", "IntPoint", "(", "y", ",", "x", ")", ")", ";", "}", "}", "}", "return", "points", ";", "}" ]
Get points after extract boundary. @param fastBitmap Image to be processed. @return List of points.
[ "Get", "points", "after", "extract", "boundary", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/effect/ExtractBoundary.java#L94-L120
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/transform/DiscreteHartleyTransform.java
DiscreteHartleyTransform.Forward
public static void Forward(double[] data) { double[] result = new double[data.length]; for (int k = 0; k < result.length; k++) { double sum = 0; for (int n = 0; n < data.length; n++) { double theta = ((2.0 * Math.PI) / data.length) * k * n; sum += data[n] * cas(theta); } result[k] = (1.0 / Math.sqrt(data.length)) * sum; } for (int i = 0; i < result.length; i++) { data[i] = result[i]; } }
java
public static void Forward(double[] data) { double[] result = new double[data.length]; for (int k = 0; k < result.length; k++) { double sum = 0; for (int n = 0; n < data.length; n++) { double theta = ((2.0 * Math.PI) / data.length) * k * n; sum += data[n] * cas(theta); } result[k] = (1.0 / Math.sqrt(data.length)) * sum; } for (int i = 0; i < result.length; i++) { data[i] = result[i]; } }
[ "public", "static", "void", "Forward", "(", "double", "[", "]", "data", ")", "{", "double", "[", "]", "result", "=", "new", "double", "[", "data", ".", "length", "]", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "result", ".", "length", ";", "k", "++", ")", "{", "double", "sum", "=", "0", ";", "for", "(", "int", "n", "=", "0", ";", "n", "<", "data", ".", "length", ";", "n", "++", ")", "{", "double", "theta", "=", "(", "(", "2.0", "*", "Math", ".", "PI", ")", "/", "data", ".", "length", ")", "*", "k", "*", "n", ";", "sum", "+=", "data", "[", "n", "]", "*", "cas", "(", "theta", ")", ";", "}", "result", "[", "k", "]", "=", "(", "1.0", "/", "Math", ".", "sqrt", "(", "data", ".", "length", ")", ")", "*", "sum", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "length", ";", "i", "++", ")", "{", "data", "[", "i", "]", "=", "result", "[", "i", "]", ";", "}", "}" ]
1-D Forward Discrete Hartley Transform. @param data Data.
[ "1", "-", "D", "Forward", "Discrete", "Hartley", "Transform", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/transform/DiscreteHartleyTransform.java#L46-L62
train
Harium/keel
src/main/java/com/harium/keel/catalano/math/transform/DiscreteHartleyTransform.java
DiscreteHartleyTransform.Forward
public static void Forward(double[][] data) { double[][] result = new double[data.length][data[0].length]; for (int m = 0; m < data.length; m++) { for (int n = 0; n < data[0].length; n++) { double sum = 0; for (int i = 0; i < result.length; i++) { for (int k = 0; k < data.length; k++) { sum += data[i][k] * cas(((2.0 * Math.PI) / data.length) * (i * m + k * n)); } result[m][n] = (1.0 / data.length) * sum; } } } for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[0].length; j++) { data[i][j] = result[i][j]; } } }
java
public static void Forward(double[][] data) { double[][] result = new double[data.length][data[0].length]; for (int m = 0; m < data.length; m++) { for (int n = 0; n < data[0].length; n++) { double sum = 0; for (int i = 0; i < result.length; i++) { for (int k = 0; k < data.length; k++) { sum += data[i][k] * cas(((2.0 * Math.PI) / data.length) * (i * m + k * n)); } result[m][n] = (1.0 / data.length) * sum; } } } for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[0].length; j++) { data[i][j] = result[i][j]; } } }
[ "public", "static", "void", "Forward", "(", "double", "[", "]", "[", "]", "data", ")", "{", "double", "[", "]", "[", "]", "result", "=", "new", "double", "[", "data", ".", "length", "]", "[", "data", "[", "0", "]", ".", "length", "]", ";", "for", "(", "int", "m", "=", "0", ";", "m", "<", "data", ".", "length", ";", "m", "++", ")", "{", "for", "(", "int", "n", "=", "0", ";", "n", "<", "data", "[", "0", "]", ".", "length", ";", "n", "++", ")", "{", "double", "sum", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "length", ";", "i", "++", ")", "{", "for", "(", "int", "k", "=", "0", ";", "k", "<", "data", ".", "length", ";", "k", "++", ")", "{", "sum", "+=", "data", "[", "i", "]", "[", "k", "]", "*", "cas", "(", "(", "(", "2.0", "*", "Math", ".", "PI", ")", "/", "data", ".", "length", ")", "*", "(", "i", "*", "m", "+", "k", "*", "n", ")", ")", ";", "}", "result", "[", "m", "]", "[", "n", "]", "=", "(", "1.0", "/", "data", ".", "length", ")", "*", "sum", ";", "}", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "data", "[", "0", "]", ".", "length", ";", "j", "++", ")", "{", "data", "[", "i", "]", "[", "j", "]", "=", "result", "[", "i", "]", "[", "j", "]", ";", "}", "}", "}" ]
2-D Forward Discrete Hartley Transform. @param data Data.
[ "2", "-", "D", "Forward", "Discrete", "Hartley", "Transform", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/transform/DiscreteHartleyTransform.java#L78-L98
train
artikcloud/artikcloud-java
src/main/java/cloud/artik/api/UsersApi.java
UsersApi.createUserProperties
public PropertiesEnvelope createUserProperties(String userId, AppProperties properties, String aid) throws ApiException { ApiResponse<PropertiesEnvelope> resp = createUserPropertiesWithHttpInfo(userId, properties, aid); return resp.getData(); }
java
public PropertiesEnvelope createUserProperties(String userId, AppProperties properties, String aid) throws ApiException { ApiResponse<PropertiesEnvelope> resp = createUserPropertiesWithHttpInfo(userId, properties, aid); return resp.getData(); }
[ "public", "PropertiesEnvelope", "createUserProperties", "(", "String", "userId", ",", "AppProperties", "properties", ",", "String", "aid", ")", "throws", "ApiException", "{", "ApiResponse", "<", "PropertiesEnvelope", ">", "resp", "=", "createUserPropertiesWithHttpInfo", "(", "userId", ",", "properties", ",", "aid", ")", ";", "return", "resp", ".", "getData", "(", ")", ";", "}" ]
Create User Application Properties Create application properties for a user @param userId User Id (required) @param properties Properties to be updated (required) @param aid Application ID (optional) @return PropertiesEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
[ "Create", "User", "Application", "Properties", "Create", "application", "properties", "for", "a", "user" ]
412f447573e7796ab4f685c0bdd5eb76185a365c
https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/UsersApi.java#L139-L142
train
artikcloud/artikcloud-java
src/main/java/cloud/artik/api/UsersApi.java
UsersApi.getUserProperties
public PropertiesEnvelope getUserProperties(String userId, String aid) throws ApiException { ApiResponse<PropertiesEnvelope> resp = getUserPropertiesWithHttpInfo(userId, aid); return resp.getData(); }
java
public PropertiesEnvelope getUserProperties(String userId, String aid) throws ApiException { ApiResponse<PropertiesEnvelope> resp = getUserPropertiesWithHttpInfo(userId, aid); return resp.getData(); }
[ "public", "PropertiesEnvelope", "getUserProperties", "(", "String", "userId", ",", "String", "aid", ")", "throws", "ApiException", "{", "ApiResponse", "<", "PropertiesEnvelope", ">", "resp", "=", "getUserPropertiesWithHttpInfo", "(", "userId", ",", "aid", ")", ";", "return", "resp", ".", "getData", "(", ")", ";", "}" ]
Get User application properties Get application properties of a user @param userId User Id (required) @param aid Application ID (optional) @return PropertiesEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
[ "Get", "User", "application", "properties", "Get", "application", "properties", "of", "a", "user" ]
412f447573e7796ab4f685c0bdd5eb76185a365c
https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/UsersApi.java#L782-L785
train
skuzzle/jeve
jeve/src/main/java/de/skuzzle/jeve/stores/AbstractListenerStore.java
AbstractListenerStore.copyList
protected <T extends Listener> Collection<T> copyList(Class<T> listenerClass, Stream<Object> listeners, int sizeHint) { if (sizeHint == 0) { return Collections.emptyList(); } return listeners .map(listenerClass::cast) .collect(Collectors.toCollection(() -> new ArrayList<>(sizeHint))); }
java
protected <T extends Listener> Collection<T> copyList(Class<T> listenerClass, Stream<Object> listeners, int sizeHint) { if (sizeHint == 0) { return Collections.emptyList(); } return listeners .map(listenerClass::cast) .collect(Collectors.toCollection(() -> new ArrayList<>(sizeHint))); }
[ "protected", "<", "T", "extends", "Listener", ">", "Collection", "<", "T", ">", "copyList", "(", "Class", "<", "T", ">", "listenerClass", ",", "Stream", "<", "Object", ">", "listeners", ",", "int", "sizeHint", ")", "{", "if", "(", "sizeHint", "==", "0", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "return", "listeners", ".", "map", "(", "listenerClass", "::", "cast", ")", ".", "collect", "(", "Collectors", ".", "toCollection", "(", "(", ")", "->", "new", "ArrayList", "<>", "(", "sizeHint", ")", ")", ")", ";", "}" ]
Creates a collection from the given stream, casting each object to the provided listener class. The returned collection must not necessarily be mutable. @param <T> Type of the listeners in the given list. @param listenerClass The class of the objects in the provided list. @param listeners The stream to obtain the listeners for the resulting collection from. @param sizeHint Expected size of the input stream. @return A typed copy of the list.
[ "Creates", "a", "collection", "from", "the", "given", "stream", "casting", "each", "object", "to", "the", "provided", "listener", "class", ".", "The", "returned", "collection", "must", "not", "necessarily", "be", "mutable", "." ]
42cc18947c9c8596c34410336e4e375e9fcd7c47
https://github.com/skuzzle/jeve/blob/42cc18947c9c8596c34410336e4e375e9fcd7c47/jeve/src/main/java/de/skuzzle/jeve/stores/AbstractListenerStore.java#L66-L74
train
Harium/keel
src/main/java/com/harium/keel/cluster/DBScan.java
DBScan.cluster
public List<Cluster> cluster(final Collection<Point2D> points) { final List<Cluster> clusters = new ArrayList<Cluster>(); final Map<Point2D, PointStatus> visited = new HashMap<Point2D, DBScan.PointStatus>(); KDTree<Point2D> tree = new KDTree<Point2D>(2); // Populate the kdTree for (final Point2D point : points) { double[] key = {point.x, point.y}; tree.insert(key, point); } for (final Point2D point : points) { if (visited.get(point) != null) { continue; } final List<Point2D> neighbors = getNeighbors(point, tree); if (neighbors.size() >= minPoints) { // DBSCAN does not care about center points final Cluster cluster = new Cluster(clusters.size()); clusters.add(expandCluster(cluster, point, neighbors, tree, visited)); } else { visited.put(point, PointStatus.NOISE); } } for (Cluster cluster : clusters) { cluster.calculateCentroid(); } return clusters; }
java
public List<Cluster> cluster(final Collection<Point2D> points) { final List<Cluster> clusters = new ArrayList<Cluster>(); final Map<Point2D, PointStatus> visited = new HashMap<Point2D, DBScan.PointStatus>(); KDTree<Point2D> tree = new KDTree<Point2D>(2); // Populate the kdTree for (final Point2D point : points) { double[] key = {point.x, point.y}; tree.insert(key, point); } for (final Point2D point : points) { if (visited.get(point) != null) { continue; } final List<Point2D> neighbors = getNeighbors(point, tree); if (neighbors.size() >= minPoints) { // DBSCAN does not care about center points final Cluster cluster = new Cluster(clusters.size()); clusters.add(expandCluster(cluster, point, neighbors, tree, visited)); } else { visited.put(point, PointStatus.NOISE); } } for (Cluster cluster : clusters) { cluster.calculateCentroid(); } return clusters; }
[ "public", "List", "<", "Cluster", ">", "cluster", "(", "final", "Collection", "<", "Point2D", ">", "points", ")", "{", "final", "List", "<", "Cluster", ">", "clusters", "=", "new", "ArrayList", "<", "Cluster", ">", "(", ")", ";", "final", "Map", "<", "Point2D", ",", "PointStatus", ">", "visited", "=", "new", "HashMap", "<", "Point2D", ",", "DBScan", ".", "PointStatus", ">", "(", ")", ";", "KDTree", "<", "Point2D", ">", "tree", "=", "new", "KDTree", "<", "Point2D", ">", "(", "2", ")", ";", "// Populate the kdTree", "for", "(", "final", "Point2D", "point", ":", "points", ")", "{", "double", "[", "]", "key", "=", "{", "point", ".", "x", ",", "point", ".", "y", "}", ";", "tree", ".", "insert", "(", "key", ",", "point", ")", ";", "}", "for", "(", "final", "Point2D", "point", ":", "points", ")", "{", "if", "(", "visited", ".", "get", "(", "point", ")", "!=", "null", ")", "{", "continue", ";", "}", "final", "List", "<", "Point2D", ">", "neighbors", "=", "getNeighbors", "(", "point", ",", "tree", ")", ";", "if", "(", "neighbors", ".", "size", "(", ")", ">=", "minPoints", ")", "{", "// DBSCAN does not care about center points", "final", "Cluster", "cluster", "=", "new", "Cluster", "(", "clusters", ".", "size", "(", ")", ")", ";", "clusters", ".", "add", "(", "expandCluster", "(", "cluster", ",", "point", ",", "neighbors", ",", "tree", ",", "visited", ")", ")", ";", "}", "else", "{", "visited", ".", "put", "(", "point", ",", "PointStatus", ".", "NOISE", ")", ";", "}", "}", "for", "(", "Cluster", "cluster", ":", "clusters", ")", "{", "cluster", ".", "calculateCentroid", "(", ")", ";", "}", "return", "clusters", ";", "}" ]
Performs DBSCAN cluster analysis. @param points the points to cluster @return the list of clusters @throws NullArgumentException if the data points are null
[ "Performs", "DBSCAN", "cluster", "analysis", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/cluster/DBScan.java#L71-L102
train
Harium/keel
src/main/java/com/harium/keel/cluster/DBScan.java
DBScan.expandCluster
private Cluster expandCluster(final Cluster cluster, final Point2D point, final List<Point2D> neighbors, final KDTree<Point2D> points, final Map<Point2D, PointStatus> visited) { cluster.addPoint(point); visited.put(point, PointStatus.PART_OF_CLUSTER); List<Point2D> seeds = new ArrayList<Point2D>(neighbors); int index = 0; while (index < seeds.size()) { Point2D current = seeds.get(index); PointStatus pStatus = visited.get(current); // only check non-visited points if (pStatus == null) { final List<Point2D> currentNeighbors = getNeighbors(current, points); if (currentNeighbors.size() >= minPoints) { seeds = merge(seeds, currentNeighbors); } } if (pStatus != PointStatus.PART_OF_CLUSTER) { visited.put(current, PointStatus.PART_OF_CLUSTER); cluster.addPoint(current); } index++; } return cluster; }
java
private Cluster expandCluster(final Cluster cluster, final Point2D point, final List<Point2D> neighbors, final KDTree<Point2D> points, final Map<Point2D, PointStatus> visited) { cluster.addPoint(point); visited.put(point, PointStatus.PART_OF_CLUSTER); List<Point2D> seeds = new ArrayList<Point2D>(neighbors); int index = 0; while (index < seeds.size()) { Point2D current = seeds.get(index); PointStatus pStatus = visited.get(current); // only check non-visited points if (pStatus == null) { final List<Point2D> currentNeighbors = getNeighbors(current, points); if (currentNeighbors.size() >= minPoints) { seeds = merge(seeds, currentNeighbors); } } if (pStatus != PointStatus.PART_OF_CLUSTER) { visited.put(current, PointStatus.PART_OF_CLUSTER); cluster.addPoint(current); } index++; } return cluster; }
[ "private", "Cluster", "expandCluster", "(", "final", "Cluster", "cluster", ",", "final", "Point2D", "point", ",", "final", "List", "<", "Point2D", ">", "neighbors", ",", "final", "KDTree", "<", "Point2D", ">", "points", ",", "final", "Map", "<", "Point2D", ",", "PointStatus", ">", "visited", ")", "{", "cluster", ".", "addPoint", "(", "point", ")", ";", "visited", ".", "put", "(", "point", ",", "PointStatus", ".", "PART_OF_CLUSTER", ")", ";", "List", "<", "Point2D", ">", "seeds", "=", "new", "ArrayList", "<", "Point2D", ">", "(", "neighbors", ")", ";", "int", "index", "=", "0", ";", "while", "(", "index", "<", "seeds", ".", "size", "(", ")", ")", "{", "Point2D", "current", "=", "seeds", ".", "get", "(", "index", ")", ";", "PointStatus", "pStatus", "=", "visited", ".", "get", "(", "current", ")", ";", "// only check non-visited points", "if", "(", "pStatus", "==", "null", ")", "{", "final", "List", "<", "Point2D", ">", "currentNeighbors", "=", "getNeighbors", "(", "current", ",", "points", ")", ";", "if", "(", "currentNeighbors", ".", "size", "(", ")", ">=", "minPoints", ")", "{", "seeds", "=", "merge", "(", "seeds", ",", "currentNeighbors", ")", ";", "}", "}", "if", "(", "pStatus", "!=", "PointStatus", ".", "PART_OF_CLUSTER", ")", "{", "visited", ".", "put", "(", "current", ",", "PointStatus", ".", "PART_OF_CLUSTER", ")", ";", "cluster", ".", "addPoint", "(", "current", ")", ";", "}", "index", "++", ";", "}", "return", "cluster", ";", "}" ]
Expands the cluster to include density-reachable items. @param cluster Cluster to expand @param point Point to add to cluster @param neighbors List of neighbors @param points the data set @param visited the set of already visited points @return the expanded cluster
[ "Expands", "the", "cluster", "to", "include", "density", "-", "reachable", "items", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/cluster/DBScan.java#L114-L143
train
Harium/keel
src/main/java/com/harium/keel/cluster/DBScan.java
DBScan.merge
private List<Point2D> merge(final List<Point2D> one, final List<Point2D> two) { final Set<Point2D> oneSet = new HashSet<Point2D>(one); for (Point2D item : two) { if (!oneSet.contains(item)) { one.add(item); } } return one; }
java
private List<Point2D> merge(final List<Point2D> one, final List<Point2D> two) { final Set<Point2D> oneSet = new HashSet<Point2D>(one); for (Point2D item : two) { if (!oneSet.contains(item)) { one.add(item); } } return one; }
[ "private", "List", "<", "Point2D", ">", "merge", "(", "final", "List", "<", "Point2D", ">", "one", ",", "final", "List", "<", "Point2D", ">", "two", ")", "{", "final", "Set", "<", "Point2D", ">", "oneSet", "=", "new", "HashSet", "<", "Point2D", ">", "(", "one", ")", ";", "for", "(", "Point2D", "item", ":", "two", ")", "{", "if", "(", "!", "oneSet", ".", "contains", "(", "item", ")", ")", "{", "one", ".", "add", "(", "item", ")", ";", "}", "}", "return", "one", ";", "}" ]
Merges two lists together. @param one first list @param two second list @return merged lists
[ "Merges", "two", "lists", "together", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/cluster/DBScan.java#L168-L176
train
Harium/keel
src/main/java/com/harium/keel/effect/neuroph/LetterSeparation.java
LetterSeparation.apply
public ImageSource apply(ImageSource input) { ImageSource originalImage = input; int width = originalImage.getWidth(); int height = originalImage.getHeight(); boolean[][] matrix = new boolean[width][height]; // black n white boolean matrix; true = blck, false = white // Copy ImageSource filteredImage = new MatrixSource(input); int[] histogram = OtsuBinarize.imageHistogram(originalImage); int totalNumberOfpixels = height * width; int threshold = OtsuBinarize.threshold(histogram, totalNumberOfpixels); int black = 0; int white = 255; int gray; int alpha; int newColor; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { gray = originalImage.getGray(i, j); if (gray > threshold) { matrix[i][j] = false; } else { matrix[i][j] = true; } } } int blackTreshold = letterThreshold(originalImage, matrix); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { gray = originalImage.getGray(i, j); alpha = originalImage.getA(i, j); if (gray > blackTreshold) { newColor = white; } else { newColor = black; } newColor = ColorHelper.getARGB(newColor, newColor, newColor, alpha); filteredImage.setRGB(i, j, newColor); } } return filteredImage; }
java
public ImageSource apply(ImageSource input) { ImageSource originalImage = input; int width = originalImage.getWidth(); int height = originalImage.getHeight(); boolean[][] matrix = new boolean[width][height]; // black n white boolean matrix; true = blck, false = white // Copy ImageSource filteredImage = new MatrixSource(input); int[] histogram = OtsuBinarize.imageHistogram(originalImage); int totalNumberOfpixels = height * width; int threshold = OtsuBinarize.threshold(histogram, totalNumberOfpixels); int black = 0; int white = 255; int gray; int alpha; int newColor; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { gray = originalImage.getGray(i, j); if (gray > threshold) { matrix[i][j] = false; } else { matrix[i][j] = true; } } } int blackTreshold = letterThreshold(originalImage, matrix); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { gray = originalImage.getGray(i, j); alpha = originalImage.getA(i, j); if (gray > blackTreshold) { newColor = white; } else { newColor = black; } newColor = ColorHelper.getARGB(newColor, newColor, newColor, alpha); filteredImage.setRGB(i, j, newColor); } } return filteredImage; }
[ "public", "ImageSource", "apply", "(", "ImageSource", "input", ")", "{", "ImageSource", "originalImage", "=", "input", ";", "int", "width", "=", "originalImage", ".", "getWidth", "(", ")", ";", "int", "height", "=", "originalImage", ".", "getHeight", "(", ")", ";", "boolean", "[", "]", "[", "]", "matrix", "=", "new", "boolean", "[", "width", "]", "[", "height", "]", ";", "// black n white boolean matrix; true = blck, false = white", "// Copy", "ImageSource", "filteredImage", "=", "new", "MatrixSource", "(", "input", ")", ";", "int", "[", "]", "histogram", "=", "OtsuBinarize", ".", "imageHistogram", "(", "originalImage", ")", ";", "int", "totalNumberOfpixels", "=", "height", "*", "width", ";", "int", "threshold", "=", "OtsuBinarize", ".", "threshold", "(", "histogram", ",", "totalNumberOfpixels", ")", ";", "int", "black", "=", "0", ";", "int", "white", "=", "255", ";", "int", "gray", ";", "int", "alpha", ";", "int", "newColor", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "width", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "height", ";", "j", "++", ")", "{", "gray", "=", "originalImage", ".", "getGray", "(", "i", ",", "j", ")", ";", "if", "(", "gray", ">", "threshold", ")", "{", "matrix", "[", "i", "]", "[", "j", "]", "=", "false", ";", "}", "else", "{", "matrix", "[", "i", "]", "[", "j", "]", "=", "true", ";", "}", "}", "}", "int", "blackTreshold", "=", "letterThreshold", "(", "originalImage", ",", "matrix", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "width", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "height", ";", "j", "++", ")", "{", "gray", "=", "originalImage", ".", "getGray", "(", "i", ",", "j", ")", ";", "alpha", "=", "originalImage", ".", "getA", "(", "i", ",", "j", ")", ";", "if", "(", "gray", ">", "blackTreshold", ")", "{", "newColor", "=", "white", ";", "}", "else", "{", "newColor", "=", "black", ";", "}", "newColor", "=", "ColorHelper", ".", "getARGB", "(", "newColor", ",", "newColor", ",", "newColor", ",", "alpha", ")", ";", "filteredImage", ".", "setRGB", "(", "i", ",", "j", ",", "newColor", ")", ";", "}", "}", "return", "filteredImage", ";", "}" ]
radi otsu da dobije spojena crna slova i ra @param input @return the processed image
[ "radi", "otsu", "da", "dobije", "spojena", "crna", "slova", "i", "ra" ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/effect/neuroph/LetterSeparation.java#L25-L81
train
Harium/keel
src/main/java/com/harium/keel/catalano/core/ArraysUtil.java
ArraysUtil.Argsort
public static int[] Argsort(final float[] array, final boolean ascending) { Integer[] indexes = new Integer[array.length]; for (int i = 0; i < indexes.length; i++) { indexes[i] = i; } Arrays.sort(indexes, new Comparator<Integer>() { @Override public int compare(final Integer i1, final Integer i2) { return (ascending ? 1 : -1) * Float.compare(array[i1], array[i2]); } }); return asArray(indexes); }
java
public static int[] Argsort(final float[] array, final boolean ascending) { Integer[] indexes = new Integer[array.length]; for (int i = 0; i < indexes.length; i++) { indexes[i] = i; } Arrays.sort(indexes, new Comparator<Integer>() { @Override public int compare(final Integer i1, final Integer i2) { return (ascending ? 1 : -1) * Float.compare(array[i1], array[i2]); } }); return asArray(indexes); }
[ "public", "static", "int", "[", "]", "Argsort", "(", "final", "float", "[", "]", "array", ",", "final", "boolean", "ascending", ")", "{", "Integer", "[", "]", "indexes", "=", "new", "Integer", "[", "array", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "indexes", ".", "length", ";", "i", "++", ")", "{", "indexes", "[", "i", "]", "=", "i", ";", "}", "Arrays", ".", "sort", "(", "indexes", ",", "new", "Comparator", "<", "Integer", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "final", "Integer", "i1", ",", "final", "Integer", "i2", ")", "{", "return", "(", "ascending", "?", "1", ":", "-", "1", ")", "*", "Float", ".", "compare", "(", "array", "[", "i1", "]", ",", "array", "[", "i2", "]", ")", ";", "}", "}", ")", ";", "return", "asArray", "(", "indexes", ")", ";", "}" ]
Returns the indices that would sort an array. @param array Array. @param ascending Ascending order. @return Array of indices.
[ "Returns", "the", "indices", "that", "would", "sort", "an", "array", "." ]
0369ae674f9e664bccc5f9e161ae7e7a3b949a1e
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/core/ArraysUtil.java#L105-L117
train