code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
public static int probRound(double value, Random rand) { if (value >= 0) { double lower = Math.floor(value); double prob = value - lower; if (rand.nextDouble() < prob) { return (int) lower + 1; } else { return (int) lower; } } else { double lower = Math.floor(Math.abs(value)); double prob = Math.abs(value) - lower; if (rand.nextDouble() < prob) { return -((int) lower + 1); } else { return -(int) lower; } } }//end probRound
Rounds a double to the next nearest integer value in a probabilistic fashion (e.g. 0.8 has a 20% chance of being rounded down to 0 and a 80% chance of being rounded up to 1). In the limit, the average of the rounded numbers generated by this procedure should converge to the original double. @param value the double value @param rand the random number generator @return the resulting integer value
MathUtils::probRound
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static /*@pure@*/ double roundDouble(double value, int afterDecimalPoint) { double mask = Math.pow(10.0, (double) afterDecimalPoint); return (double) (Math.round(value * mask)) / mask; }//end roundDouble
Rounds a double to the given number of decimal places. @param value the double value @param afterDecimalPoint the number of digits after the decimal point @return the double rounded to the given precision
MathUtils::roundDouble
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static /*@pure@*/ float roundFloat(float value, int afterDecimalPoint) { float mask = (float) Math.pow(10, (float) afterDecimalPoint); return (float) (Math.round(value * mask)) / mask; }//end roundDouble
Rounds a double to the given number of decimal places. @param value the double value @param afterDecimalPoint the number of digits after the decimal point @return the double rounded to the given precision
MathUtils::roundFloat
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static double bernoullis(double n, double k, double successProb) { double combo = MathUtils.combination(n, k); double p = successProb; double q = 1 - successProb; return combo * Math.pow(p, k) * Math.pow(q, n - k); }//end bernoullis
This will return the bernoulli trial for the given event. A bernoulli trial is a mechanism for detecting the probability of a given event occurring k times in n independent trials @param n the number of trials @param k the number of times the target event occurs @param successProb the probability of the event happening @return the probability of the given event occurring k times.
MathUtils::bernoullis
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static /*@pure@*/ boolean sm(double a, double b) { return (b - a > SMALL); }
Tests if a is smaller than b. @param a a double @param b a double
MathUtils::sm
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static /*@pure@*/ boolean gr(double a, double b) { return (a - b > SMALL); }
Tests if a is greater than b. @param a a double @param b a double
MathUtils::gr
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static double[] fromString(String data, String separator) { String[] split = data.split(separator); double[] ret = new double[split.length]; for (int i = 0; i < split.length; i++) { ret[i] = Double.parseDouble(split[i]); } return ret; }//end fromString
This will take a given string and separator and convert it to an equivalent double array. @param data the data to separate @param separator the separator to use @return the new double array based on the given data
MathUtils::fromString
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static /*@pure@*/ double mean(double[] vector) { double sum = 0; if (vector.length == 0) { return 0; } for (int i = 0; i < vector.length; i++) { sum += vector[i]; } return sum / (double) vector.length; }//end mean
Computes the mean for an array of doubles. @param vector the array @return the mean
MathUtils::mean
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static int toDecimal(String binary) { long num = Long.parseLong(binary); long rem; /* Use the remainder method to ensure validity */ while (num > 0) { rem = num % 10; num = num / 10; if (rem != 0 && rem != 1) { System.out.println("This is not a binary number."); System.out.println("Please try once again."); return -1; } } int i = Integer.parseInt(binary, 2); return i; }//end toDecimal
This will convert the given binary string to a decimal based integer @param binary the binary string to convert @return an equivalent base 10 number
MathUtils::toDecimal
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static int distanceFinderZValue(double[] vector) { StringBuilder binaryBuffer = new StringBuilder(); List<String> binaryReps = new ArrayList<String>(vector.length); for (int i = 0; i < vector.length; i++) { double d = vector[i]; int j = (int) d; String binary = Integer.toBinaryString(j); binaryReps.add(binary); } //append from left to right, the least to the most significant bit //till all strings are empty while (!binaryReps.isEmpty()) { for (int j = 0; j < binaryReps.size(); j++) { String curr = binaryReps.get(j); if (!curr.isEmpty()) { char first = curr.charAt(0); binaryBuffer.append(first); curr = curr.substring(1); binaryReps.set(j, curr); } else binaryReps.remove(j); } } return Integer.parseInt(binaryBuffer.toString(), 2); }//end distanceFinderZValue
This will translate a vector in to an equivalent integer @param vector the vector to translate @return a z value such that the value is the interleaved lsd to msd for each double in the vector
MathUtils::distanceFinderZValue
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static double euclideanDistance(double[] p, double[] q) { double ret = 0; for (int i = 0; i < p.length; i++) { double diff = (q[i] - p[i]); double sq = Math.pow(diff, 2); ret += sq; } return ret; }//end euclideanDistance
This returns the euclidean distance of two vectors sum(i=1,n) (q_i - p_i)^2 @param p the first vector @param q the second vector @return the euclidean distance between two vectors
MathUtils::euclideanDistance
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static double euclideanDistance(float[] p, float[] q) { double ret = 0; for (int i = 0; i < p.length; i++) { double diff = (q[i] - p[i]); double sq = Math.pow(diff, 2); ret += sq; } return ret; }//end euclideanDistance
This returns the euclidean distance of two vectors sum(i=1,n) (q_i - p_i)^2 @param p the first vector @param q the second vector @return the euclidean distance between two vectors
MathUtils::euclideanDistance
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static double[] generateUniform(int l) { double[] ret = new double[l]; Random rgen = new Random(); for (int i = 0; i < l; i++) { ret[i] = rgen.nextDouble(); } return ret; }//end generateUniform
This will generate a series of uniformally distributed numbers between l times @param l the number of numbers to generate @return l uniformally generated numbers
MathUtils::generateUniform
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static double manhattanDistance(double[] p, double[] q) { double ret = 0; for (int i = 0; i < p.length; i++) { double difference = p[i] - q[i]; ret += Math.abs(difference); } return ret; }//end manhattanDistance
This will calculate the Manhattan distance between two sets of points. The Manhattan distance is equivalent to: 1_sum_n |p_i - q_i| @param p the first point vector @param q the second point vector @return the Manhattan distance between two object
MathUtils::manhattanDistance
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static int randomNumberBetween(double begin, double end,double anchor) { if (begin > end) throw new IllegalArgumentException("Begin must not be less than end"); return (int) begin + (int) (anchor * ((end - begin) + 1)); }
Generates a random integer between the specified numbers @param begin the begin of the interval @param end the end of the interval @param anchor the base number (assuming to be generated from an external rng) @return an int between begin and end
MathUtils::randomNumberBetween
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static int randomNumberBetween(double begin, double end) { if (begin > end) throw new IllegalArgumentException("Begin must not be less than end"); return (int) begin + (int) (Math.random() * ((end - begin) + 1)); }
Generates a random integer between the specified numbers @param begin the begin of the interval @param end the end of the interval @return an int between begin and end
MathUtils::randomNumberBetween
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static int randomNumberBetween(double begin, double end, RandomGenerator rng) { if (begin > end) throw new IllegalArgumentException("Begin must not be less than end"); return (int) begin + (int) (rng.nextDouble() * ((end - begin) + 1)); }
Generates a random integer between the specified numbers @param begin the begin of the interval @param end the end of the interval @return an int between begin and end
MathUtils::randomNumberBetween
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public double slope(double x1, double x2, double y1, double y2) { return (y2 - y1) / (x2 - x1); }//end slope
This returns the slope of the given points. @param x1 the first x to use @param x2 the end x to use @param y1 the begin y to use @param y2 the end y to use @return the slope of the given points
MathUtils::slope
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static void shuffleArray(int[] array, long rngSeed) { shuffleArray(array, new Random(rngSeed)); }
Shuffle the array elements using the specified RNG seed. Uses Fisher Yates shuffle internally: <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm"> https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm</a> @param array Array to shuffle @param rngSeed RNG seed to use for shuffling
MathUtils::shuffleArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static void shuffleArray(int[] array, Random rng) { shuffleArraySubset(array, array.length, rng); }
Shuffle the array elements using the specified Random instance Uses Fisher Yates shuffle internally: <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm"> https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm</a> @param array Array to shuffle @param rng Random instance to use for shuffling
MathUtils::shuffleArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static void shuffleArraySubset(int[] array, int shuffleFirst, Random rng) { for (int i = shuffleFirst-1; i > 0; i--) { int j = rng.nextInt(i + 1); int temp = array[j]; array[j] = array[i]; array[i] = temp; } }
Shuffle the first N elements of the array using the specified Random instance.<br> If shuffleFirst < array.length, only the elements 0 to shuffleFirst-1 are modified; values at indices shuffleFirst to array.length-1 are not changed. Uses Fisher Yates shuffle internally: <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm"> https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm</a> @param array Array to shuffle first N elements of @param rng Random instance to use for shuffling
MathUtils::shuffleArraySubset
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public static int hashCode(double value) { long bits = Double.doubleToLongBits(value); return (int) (bits ^ (bits >>> 32)); }
hashCode method, taken from Java 1.8 Double.hashCode(double) method @param value Double value to hash @return Hash code for the double value
MathUtils::hashCode
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java
Apache-2.0
public Rational() { a = BigInteger.ZERO; b = BigInteger.ONE; }
Default ctor, which represents the zero.
Rational::Rational
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational(BigInteger a, BigInteger b) { this.a = a; this.b = b; normalize(); }
ctor from a numerator and denominator. @param a the numerator. @param b the denominator.
Rational::Rational
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational(BigInteger a) { this.a = a; b = BigInteger.valueOf(1); }
ctor from a numerator. @param a the BigInteger.
Rational::Rational
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational(int a, int b) { this(BigInteger.valueOf(a), BigInteger.valueOf(b)); }
ctor from a numerator and denominator. @param a the numerator. @param b the denominator.
Rational::Rational
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational(String str) throws NumberFormatException { this(str, 10); }
ctor from a string representation. @param str the string. This either has a slash in it, separating two integers, or, if there is no slash, is representing the numerator with implicit denominator equal to 1. @warning this does not yet test for a denominator equal to zero
Rational::Rational
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational(String str, int radix) throws NumberFormatException { int hasslah = str.indexOf("/"); if (hasslah == -1) { a = new BigInteger(str, radix); b = new BigInteger("1", radix); /* no normalization necessary here */ } else { /* create numerator and denominator separately */ a = new BigInteger(str.substring(0, hasslah), radix); b = new BigInteger(str.substring(hasslah + 1), radix); normalize(); } }
ctor from a string representation in a specified base. @param str the string. This either has a slash in it, separating two integers, or, if there is no slash, is just representing the numerator. @param radix the number base for numerator and denominator @warning this does not yet test for a denominator equal to zero 5
Rational::Rational
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public static Rational binomial(Rational n, BigInteger m) { if (m.compareTo(BigInteger.ZERO) == 0) { return Rational.ONE; } Rational bin = n; for (BigInteger i = BigInteger.valueOf(2); i.compareTo(m) != 1; i = i.add(BigInteger.ONE)) { bin = bin.multiply(n.subtract(i.subtract(BigInteger.ONE))).divide(i); } return bin; } /* Rational.binomial */
binomial (n choose m). @param n the numerator. Equals the size of the set to choose from. @param m the denominator. Equals the number of elements to select. @return the binomial coefficient.
Rational::binomial
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public static Rational binomial(Rational n, int m) { if (m == 0) { return Rational.ONE; } Rational bin = n; for (int i = 2; i <= m; i++) { bin = bin.multiply(n.subtract(i - 1)).divide(i); } return bin; } /* Rational.binomial */
binomial (n choose m). @param n the numerator. Equals the size of the set to choose from. @param m the denominator. Equals the number of elements to select. @return the binomial coefficient.
Rational::binomial
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational multiply(final Rational val) { BigInteger num = a.multiply(val.a); BigInteger deno = b.multiply(val.b); /* Normalization to an coprime format will be done inside * the ctor() and is not duplicated here. */ return (new Rational(num, deno)); } /* Rational.multiply */
Multiply by another fraction. @param val a second rational number. @return the product of this with the val.
Rational::multiply
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational multiply(final BigInteger val) { Rational val2 = new Rational(val, BigInteger.ONE); return (multiply(val2)); } /* Rational.multiply */
Multiply by a BigInteger. @param val a second number. @return the product of this with the value.
Rational::multiply
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational multiply(final int val) { BigInteger tmp = BigInteger.valueOf(val); return multiply(tmp); } /* Rational.multiply */
Multiply by an integer. @param val a second number. @return the product of this with the value.
Rational::multiply
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational pow(int exponent) { if (exponent == 0) { return new Rational(1, 1); } BigInteger num = a.pow(Math.abs(exponent)); BigInteger deno = b.pow(Math.abs(exponent)); if (exponent > 0) { return (new Rational(num, deno)); } else { return (new Rational(deno, num)); } } /* Rational.pow */
Power to an integer. @param exponent the exponent. @return this value raised to the power given by the exponent. If the exponent is 0, the value 1 is returned.
Rational::pow
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational pow(BigInteger exponent) throws NumberFormatException { /* test for overflow */ if (exponent.compareTo(MAX_INT) == 1) { throw new NumberFormatException("Exponent " + exponent.toString() + " too large."); } if (exponent.compareTo(MIN_INT) == -1) { throw new NumberFormatException("Exponent " + exponent.toString() + " too small."); } /* promote to the simpler interface above */ return pow(exponent.intValue()); } /* Rational.pow */
Power to an integer. @param exponent the exponent. @return this value raised to the power given by the exponent. If the exponent is 0, the value 1 is returned.
Rational::pow
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational divide(final Rational val) { BigInteger num = a.multiply(val.b); BigInteger deno = b.multiply(val.a); /* Reduction to a coprime format is done inside the ctor, * and not repeated here. */ return (new Rational(num, deno)); } /* Rational.divide */
Divide by another fraction. @param val A second rational number. @return The value of this/val
Rational::divide
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational divide(BigInteger val) { Rational val2 = new Rational(val, BigInteger.ONE); return (divide(val2)); } /* Rational.divide */
Divide by an integer. @param val a second number. @return the value of this/val
Rational::divide
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational divide(int val) { Rational val2 = new Rational(val, 1); return (divide(val2)); } /* Rational.divide */
Divide by an integer. @param val A second number. @return The value of this/val
Rational::divide
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational add(Rational val) { BigInteger num = a.multiply(val.b).add(b.multiply(val.a)); BigInteger deno = b.multiply(val.b); return (new Rational(num, deno)); } /* Rational.add */
Add another fraction. @param val The number to be added @return this+val.
Rational::add
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational add(BigInteger val) { Rational val2 = new Rational(val, BigInteger.ONE); return (add(val2)); } /* Rational.add */
Add another integer. @param val The number to be added @return this+val.
Rational::add
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational negate() { return (new Rational(a.negate(), b)); } /* Rational.negate */
Compute the negative. @return -this.
Rational::negate
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational subtract(Rational val) { Rational val2 = val.negate(); return (add(val2)); } /* Rational.subtract */
Subtract another fraction. 7 @param val the number to be subtracted from this @return this - val.
Rational::subtract
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational subtract(BigInteger val) { Rational val2 = new Rational(val, BigInteger.ONE); return (subtract(val2)); } /* Rational.subtract */
Subtract an integer. @param val the number to be subtracted from this @return this - val.
Rational::subtract
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational subtract(int val) { Rational val2 = new Rational(val, 1); return (subtract(val2)); } /* Rational.subtract */
Subtract an integer. @param val the number to be subtracted from this @return this - val.
Rational::subtract
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public BigInteger numer() { return a; }
Get the numerator. @return The numerator of the reduced fraction.
Rational::numer
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public BigInteger denom() { return b; }
Get the denominator. @return The denominator of the reduced fraction.
Rational::denom
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational abs() { return (new Rational(a.abs(), b.abs())); }
Absolute value. @return The absolute (non-negative) value of this.
Rational::abs
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public BigInteger floor() { /* is already integer: return the numerator */ if (b.compareTo(BigInteger.ONE) == 0) { return a; } else if (a.compareTo(BigInteger.ZERO) > 0) { return a.divide(b); } else { return a.divide(b).subtract(BigInteger.ONE); } } /* Rational.floor */
floor(): the nearest integer not greater than this. @return The integer rounded towards negative infinity.
Rational::floor
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public BigInteger trunc() { /* is already integer: return the numerator */ if (b.compareTo(BigInteger.ONE) == 0) { return a; } else { return a.divide(b); } } /* Rational.trunc */
Remove the fractional part. @return The integer rounded towards zero.
Rational::trunc
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public int compareTo(final Rational val) { /* Since we have always kept the denominators positive, * simple cross-multiplying works without changing the sign. */ final BigInteger left = a.multiply(val.b); final BigInteger right = val.a.multiply(b); return left.compareTo(right); } /* Rational.compareTo */
Compares the value of this with another constant. @param val the other constant to compare with @return -1, 0 or 1 if this number is numerically less than, equal to, or greater than val.
Rational::compareTo
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public int compareTo(final BigInteger val) { final Rational val2 = new Rational(val, BigInteger.ONE); return (compareTo(val2)); } /* Rational.compareTo */
Compares the value of this with another constant. @param val the other constant to compare with @return -1, 0 or 1 if this number is numerically less than, equal to, or greater than val.
Rational::compareTo
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public double doubleValue() { /* To meet the risk of individual overflows of the exponents of * a separate invocation a.doubleValue() or b.doubleValue(), we divide first * in a BigDecimal environment and converst the result. */ BigDecimal adivb = (new BigDecimal(a)).divide(new BigDecimal(b), MathContext.DECIMAL128); return adivb.doubleValue(); } /* Rational.doubleValue */
Return a double value representation. @return The value with double precision.
Rational::doubleValue
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public float floatValue() { BigDecimal adivb = (new BigDecimal(a)).divide(new BigDecimal(b), MathContext.DECIMAL128); return adivb.floatValue(); } /* Rational.floatValue */
Return a float value representation. @return The value with single precision.
Rational::floatValue
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public BigDecimal BigDecimalValue(MathContext mc) { /* numerator and denominator individually rephrased */ BigDecimal n = new BigDecimal(a); BigDecimal d = new BigDecimal(b); return n.divide(d, mc); } /* Rational.BigDecimnalValue */
Return a representation as BigDecimal. @param mc the mathematical context which determines precision, rounding mode etc @return A representation as a BigDecimal floating point number.
Rational::BigDecimalValue
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public String toFString(int digits) { if (b.compareTo(BigInteger.ONE) != 0) { MathContext mc = new MathContext(digits, RoundingMode.DOWN); BigDecimal f = (new BigDecimal(a)).divide(new BigDecimal(b), mc); return (f.toString()); } else { return a.toString(); } } /* Rational.toFString */
Return a string in floating point format. @param digits The precision (number of digits) @return The human-readable version in base 10.
Rational::toFString
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational max(final Rational val) { if (compareTo(val) > 0) { return this; } else { return val; } } /* Rational.max */
Compares the value of this with another constant. @param val The other constant to compare with @return The arithmetic maximum of this and val.
Rational::max
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational min(final Rational val) { if (compareTo(val) < 0) { return this; } else { return val; } } /* Rational.min */
Compares the value of this with another constant. @param val The other constant to compare with @return The arithmetic minimum of this and val.
Rational::min
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational Pochhammer(final BigInteger n) { if (n.compareTo(BigInteger.ZERO) < 0) { return null; } else if (n.compareTo(BigInteger.ZERO) == 0) { return Rational.ONE; } else { /* initialize results with the current value */ Rational res = new Rational(a, b); BigInteger i = BigInteger.ONE; for (; i.compareTo(n) < 0; i = i.add(BigInteger.ONE)) { res = res.multiply(add(i)); } return res; } } /* Rational.pochhammer */
Compute Pochhammer's symbol (this)_n. @param n The number of product terms in the evaluation. @return Gamma(this+n)/Gamma(this) = this*(this+1)*...*(this+n-1).
Rational::Pochhammer
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public Rational Pochhammer(int n) { return Pochhammer(BigInteger.valueOf(n)); } /* Rational.pochhammer */
Compute pochhammer's symbol (this)_n. @param n The number of product terms in the evaluation. @return Gamma(this+n)/GAMMA(this).
Rational::Pochhammer
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
protected void normalize() { /* compute greatest common divisor of numerator and denominator */ final BigInteger g = a.gcd(b); if (g.compareTo(BigInteger.ONE) > 0) { a = a.divide(g); b = b.divide(g); } if (b.compareTo(BigInteger.ZERO) == -1) { a = a.negate(); b = b.negate(); } } /* Rational.normalize */
Normalize to coprime numerator and denominator. Also copy a negative sign of the denominator to the numerator.
Rational::normalize
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/Rational.java
Apache-2.0
public static boolean[] toBooleanArray(byte[] input) { boolean[] output = new boolean[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i] != 0; } return output; }
Converts a byte array to a boolean array. @param input the input byte array @return a boolean array with true values for nonzero bytes and false values for zero bytes
ArrayUtil::toBooleanArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static boolean[] toBooleanArray(short[] input) { boolean[] output = new boolean[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i] != 0; } return output; }
Converts a short array to a boolean array. @param input the input short array @return a boolean array with true values for nonzero shorts and false values for zero shorts
ArrayUtil::toBooleanArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static boolean[] toBooleanArray(int[] input) { boolean[] output = new boolean[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i] != 0; } return output; }
Converts an int array to a boolean array. @param input the input int array @return a boolean array with true values for nonzero integers and false values for zero integers
ArrayUtil::toBooleanArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static boolean[] toBooleanArray(long[] input) { boolean[] output = new boolean[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i] != 0L; } return output; }
Converts a long array to a boolean array. @param input the input long array @return a boolean array with true values for nonzero longs and false values for zero longs
ArrayUtil::toBooleanArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static boolean[] toBooleanArray(float[] input) { boolean[] output = new boolean[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i] != 0.0f; } return output; }
Converts a float array to a boolean array. @param input the input float array @return a boolean array with true values for nonzero floats and false values for zero floats
ArrayUtil::toBooleanArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static boolean[] toBooleanArray(double[] input) { boolean[] output = new boolean[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i] != 0.0; } return output; }
Converts a double array to a boolean array. @param input the input double array @return a boolean array with true values for nonzero doubles and false values for zero doubles
ArrayUtil::toBooleanArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static boolean[] fromFloat(float[] elements) { boolean[] ret = new boolean[elements.length]; for(int i = 0; i < elements.length; i++) { ret[i] = elements[i] == 0.0f ? false : true; } return ret; }
Create a boolean array from a float array. @param elements the elements to create @return the returned float array
ArrayUtil::fromFloat
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static boolean[] nTimes(boolean element,int n) { boolean[] ret = new boolean[n]; //boolean values default to false. Only need to iterate when true. if(element) { for (int i = 0; i < n; i++) { ret[i] = element; } } return ret; }
Generate an array with n elements of the same specified value. @param element the element to create n copies of @param n the number of elements @return the created array
ArrayUtil::nTimes
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static int[] toIntArray(short[] input) { int[] output = new int[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a short array to an int array. @param input the input short array @return an int array with each element equal to the corresponding short value
ArrayUtil::toIntArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static int[] toIntArray(boolean[] input) { int[] output = new int[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i] ? 1 : 0; } return output; }
Converts a short array to an int array. @param input the input short array @return an int array with each element equal to the corresponding int value
ArrayUtil::toIntArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static int[] toIntArray(char[] input) { int[] output = new int[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a char array to an int array. @param input the input char array @return an int array with each element equal to the corresponding char value
ArrayUtil::toIntArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static int[] toIntArray(int[] input) { int[] output = new int[input.length]; System.arraycopy(input, 0, output, 0, input.length); return output; }
Converts an int array to an int array (i.e., returns a copy of the input array). @param input the input int array @return a new int array with the same values as the input array
ArrayUtil::toIntArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static int[] toIntArray(long[] input) { int[] output = new int[input.length]; for (int i = 0; i < input.length; i++) { output[i] = (int) input[i]; } return output; }
Converts a long array to an int array. @param input the input long array @return an int array with each element equal to the corresponding long value cast to an int
ArrayUtil::toIntArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static int[] toIntArray(float[] input) { int[] output = new int[input.length]; for (int i = 0; i < input.length; i++) { output[i] = (int) input[i]; } return output; }
Converts a float array to an int array. @param input the input float array @return an int array with each element equal to the corresponding float value cast to an int
ArrayUtil::toIntArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static int[] toIntArray(double[] input) { int[] output = new int[input.length]; for (int i = 0; i < input.length; i++) { output[i] = (int) input[i]; } return output; }
Converts a double array to an int array. @param input the input double array @return an int array with each element equal to the corresponding double value cast to an int
ArrayUtil::toIntArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static double[] toDoubleArray(short[] input) { double[] output = new double[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a short array to a double array. @param input the input short array @return a double array with each element equal to the corresponding short value
ArrayUtil::toDoubleArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static double[] toDoubleArray(char[] input) { double[] output = new double[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a char array to a double array. @param input the input char array @return a double array with each element equal to the corresponding char value
ArrayUtil::toDoubleArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static double[] toDoubleArray(boolean[] input) { double[] output = new double[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i] ? 1.0 : 0.0; } return output; }
Converts a boolean array to a double array. @param input the input boolean array @return a double array with each element equal to the corresponding double value
ArrayUtil::toDoubleArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static double[] toDoubleArray(int[] input) { double[] output = new double[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts an int array to a double array. @param input the input int array @return a double array with each element equal to the corresponding int value
ArrayUtil::toDoubleArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static double[] toDoubleArray(long[] input) { double[] output = new double[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a long array to a double array. @param input the input long array @return a double array with each element equal to the corresponding long value
ArrayUtil::toDoubleArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static double[] toDoubleArray(float[] input) { double[] output = new double[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a float array to a double array. @param input the input float array @return a double array with each element equal to the corresponding float value
ArrayUtil::toDoubleArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static double[] toDoubleArray(double[] input) { double[] output = new double[input.length]; System.arraycopy(input, 0, output, 0, input.length); return output; }
Converts a double array to a double array (i.e., returns a copy of the input array). @param input the input double array @return a new double array with the same values as the input array
ArrayUtil::toDoubleArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static long[] toLongArray(byte[] input) { long[] output = new long[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a byte array to a long array. @param input the input byte array @return a long array with each element equal to the corresponding byte value
ArrayUtil::toLongArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static long[] toLongArray(boolean[] input) { long[] output = new long[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i] ? 1 : 0; } return output; }
Converts a byte array to a long array. @param input the input boolean array @return a long array with each element equal to the corresponding long value
ArrayUtil::toLongArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static long[] toLongArray(short[] input) { long[] output = new long[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a short array to a long array. @param input the input short array @return a long array with each element equal to the corresponding short value
ArrayUtil::toLongArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static long[] toLongArray(char[] input) { long[] output = new long[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a char array to a long array. @param input the input char array @return a long array with each element equal to the corresponding char value
ArrayUtil::toLongArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static long[] toLongArrayInt(int[] input) { long[] output = new long[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts an int array to a long array. @param input the input int array @return a long array with each element equal to the corresponding int value
ArrayUtil::toLongArrayInt
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static long[] toLongArrayFloat(float[] input) { long[] output = new long[input.length]; for (int i = 0; i < input.length; i++) { output[i] = (long) input[i]; } return output; }
Converts a float array to a long array. @param input the input float array @return a long array with each element equal to the corresponding float value
ArrayUtil::toLongArrayFloat
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static long[] toLongArray(double[] input) { long[] output = new long[input.length]; for (int i = 0; i < input.length; i++) { output[i] = (long) input[i]; } return output; }
Converts a double array to a long array. @param input the input double array @return a long array with each element equal to the corresponding double value
ArrayUtil::toLongArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static long[] toLongArray(long[] input) { long[] output = new long[input.length]; System.arraycopy(input, 0, output, 0, input.length); return output; }
Converts a long array to a long array (i.e., returns a copy of the input array). @param input the input long array @return a new long array with the same values as the input array
ArrayUtil::toLongArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static float[] toFloatArray(short[] input) { float[] output = new float[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a short array to a float array. @param input the input short array @return a float array with each element equal to the corresponding short value
ArrayUtil::toFloatArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static float[] toFloatArray(boolean[] input) { float[] output = new float[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i] ? 1.0f : 0.0f; } return output; }
Converts a boolean array to a float array. @param input the input boolean array @return a float array with each element equal to the corresponding boolean value
ArrayUtil::toFloatArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static float[] toFloatArray(char[] input) { float[] output = new float[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a char array to a float array. @param input the input char array @return a float array with each element equal to the corresponding char value
ArrayUtil::toFloatArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static float[] toFloatArray(int[] input) { float[] output = new float[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts an int array to a float array. @param input the input int array @return a float array with each element equal to the corresponding int value
ArrayUtil::toFloatArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static float[] toFloatArray(long[] input) { float[] output = new float[input.length]; for (int i = 0; i < input.length; i++) { output[i] = input[i]; } return output; }
Converts a long array to a float array. @param input the input long array @return a float array with each element equal to the corresponding long value
ArrayUtil::toFloatArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static float[] toFloatArray(double[] input) { float[] output = new float[input.length]; for (int i = 0; i < input.length; i++) { output[i] = (float) input[i]; } return output; }
Converts a double array to a float array. @param input the input double array @return a float array with each element equal to the corresponding double value
ArrayUtil::toFloatArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static float[] toFloatArray(float[] input) { float[] output = new float[input.length]; System.arraycopy(input, 0, output, 0, input.length); return output; }
Converts a float array to a float array (i.e., returns a copy of the input array). @param input the input float array @return a new float array with the same values as the input array
ArrayUtil::toFloatArray
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static <T> T[] concat(Class<T> clazz,T[]...arrs) { int totalLength = 0; for(T[] arr : arrs) totalLength += arr.length; T[] ret = (T[]) Array.newInstance(clazz,totalLength); int count = 0; for(T[] arr : arrs) { for(T input : arr) { ret[count] = input; count++; } } return ret; }
Concat all the elements @param arrs the input arrays @return @param <T>
ArrayUtil::concat
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static boolean containsAnyNegative(int[] arr) { if(arr == null) return false; for(int i = 0; i < arr.length; i++) { if(arr[i] < 0) return true; } return false; }
Returns true if any array elements are negative. If the array is null, it returns false @param arr the array to test @return
ArrayUtil::containsAnyNegative
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0
public static boolean anyLargerThan(int[] arrs, int check) { for(int i = 0; i < arrs.length; i++) { if(arrs[i] > check) return true; } return false; }
@param arrs @param check @return
ArrayUtil::anyLargerThan
java
deeplearning4j/deeplearning4j
nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-common/src/main/java/org/nd4j/common/util/ArrayUtil.java
Apache-2.0