code
stringlengths
67
466k
docstring
stringlengths
1
13.2k
public WhitelistEnvelope enableWhitelist(String dtid, DeviceTypeUpdateInput deviceTypeUpdateInfo) throws ApiException { ApiResponse<WhitelistEnvelope> resp = enableWhitelistWithHttpInfo(dtid, deviceTypeUpdateInfo); return resp.getData(); }
Enable or disble whitelist feature of a device type Enable or disble whitelist feature of a device type @param dtid Device Type ID. (required) @param deviceTypeUpdateInfo Device type update input. (required) @return WhitelistEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<WhitelistEnvelope> enableWhitelistWithHttpInfo(String dtid, DeviceTypeUpdateInput deviceTypeUpdateInfo) throws ApiException { com.squareup.okhttp.Call call = enableWhitelistValidateBeforeCall(dtid, deviceTypeUpdateInfo, null, null); Type localVarReturnType = new TypeToken<WhitelistEnvelope>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
Enable or disble whitelist feature of a device type Enable or disble whitelist feature of a device type @param dtid Device Type ID. (required) @param deviceTypeUpdateInfo Device type update input. (required) @return ApiResponse&lt;WhitelistEnvelope&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public RejectedCSVRowsEnvelope getRejectedRowList(String dtid, String uploadId, Integer count, Integer offset) throws ApiException { ApiResponse<RejectedCSVRowsEnvelope> resp = getRejectedRowListWithHttpInfo(dtid, uploadId, count, offset); return resp.getData(); }
Get the list of rejected rows for an uploaded CSV file. Get the list of rejected rows for an uploaded CSV file. @param dtid Device type id related to the uploaded CSV file. (required) @param uploadId Upload id related to the uploaded CSV file. (required) @param count Max results count. (optional) @param offset Result starting offset. (optional) @return RejectedCSVRowsEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<RejectedCSVRowsEnvelope> getRejectedRowListWithHttpInfo(String dtid, String uploadId, Integer count, Integer offset) throws ApiException { com.squareup.okhttp.Call call = getRejectedRowListValidateBeforeCall(dtid, uploadId, count, offset, null, null); Type localVarReturnType = new TypeToken<RejectedCSVRowsEnvelope>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
Get the list of rejected rows for an uploaded CSV file. Get the list of rejected rows for an uploaded CSV file. @param dtid Device type id related to the uploaded CSV file. (required) @param uploadId Upload id related to the uploaded CSV file. (required) @param count Max results count. (optional) @param offset Result starting offset. (optional) @return ApiResponse&lt;RejectedCSVRowsEnvelope&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public UploadStatusEnvelope getUploadStatus(String dtid, String uploadId) throws ApiException { ApiResponse<UploadStatusEnvelope> resp = getUploadStatusWithHttpInfo(dtid, uploadId); return resp.getData(); }
Get the status of a uploaded CSV file. Get the status of a uploaded CSV file. @param dtid Device type id related to the uploaded CSV file. (required) @param uploadId Upload id related to the uploaded CSV file. (required) @return UploadStatusEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<UploadStatusEnvelope> getUploadStatusWithHttpInfo(String dtid, String uploadId) throws ApiException { com.squareup.okhttp.Call call = getUploadStatusValidateBeforeCall(dtid, uploadId, null, null); Type localVarReturnType = new TypeToken<UploadStatusEnvelope>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
Get the status of a uploaded CSV file. Get the status of a uploaded CSV file. @param dtid Device type id related to the uploaded CSV file. (required) @param uploadId Upload id related to the uploaded CSV file. (required) @return ApiResponse&lt;UploadStatusEnvelope&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public WhitelistResultEnvelope getWhitelist(String dtid, Integer count, Integer offset) throws ApiException { ApiResponse<WhitelistResultEnvelope> resp = getWhitelistWithHttpInfo(dtid, count, offset); return resp.getData(); }
Get whitelisted vdids of a device type. Get whitelisted vdids of a device type. @param dtid Device Type ID. (required) @param count Max results count. (optional) @param offset Result starting offset. (optional) @return WhitelistResultEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<WhitelistResultEnvelope> getWhitelistWithHttpInfo(String dtid, Integer count, Integer offset) throws ApiException { com.squareup.okhttp.Call call = getWhitelistValidateBeforeCall(dtid, count, offset, null, null); Type localVarReturnType = new TypeToken<WhitelistResultEnvelope>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
Get whitelisted vdids of a device type. Get whitelisted vdids of a device type. @param dtid Device Type ID. (required) @param count Max results count. (optional) @param offset Result starting offset. (optional) @return ApiResponse&lt;WhitelistResultEnvelope&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public CertificateEnvelope getWhitelistCertificate(String dtid) throws ApiException { ApiResponse<CertificateEnvelope> resp = getWhitelistCertificateWithHttpInfo(dtid); return resp.getData(); }
Get whitelist certificate of device type. Get whitelist certificate of device type. @param dtid Device Type ID. (required) @return CertificateEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<CertificateEnvelope> getWhitelistCertificateWithHttpInfo(String dtid) throws ApiException { com.squareup.okhttp.Call call = getWhitelistCertificateValidateBeforeCall(dtid, null, null); Type localVarReturnType = new TypeToken<CertificateEnvelope>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
Get whitelist certificate of device type. Get whitelist certificate of device type. @param dtid Device Type ID. (required) @return ApiResponse&lt;CertificateEnvelope&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public WhitelistEnvelope getWhitelistStatus(String dtid) throws ApiException { ApiResponse<WhitelistEnvelope> resp = getWhitelistStatusWithHttpInfo(dtid); return resp.getData(); }
Get the status of whitelist feature (enabled/disabled) of a device type. Get the status of whitelist feature (enabled/disabled) of a device type. @param dtid Device Type ID. (required) @return WhitelistEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<WhitelistEnvelope> getWhitelistStatusWithHttpInfo(String dtid) throws ApiException { com.squareup.okhttp.Call call = getWhitelistStatusValidateBeforeCall(dtid, null, null); Type localVarReturnType = new TypeToken<WhitelistEnvelope>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
Get the status of whitelist feature (enabled/disabled) of a device type. Get the status of whitelist feature (enabled/disabled) of a device type. @param dtid Device Type ID. (required) @return ApiResponse&lt;WhitelistEnvelope&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public UploadIdEnvelope uploadCSV(String dtid, byte[] file) throws ApiException { ApiResponse<UploadIdEnvelope> resp = uploadCSVWithHttpInfo(dtid, file); return resp.getData(); }
Upload a CSV file related to the Device Type. Upload a CSV file related to the Device Type. @param dtid Device Type ID. (required) @param file Device Type ID. (required) @return UploadIdEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<UploadIdEnvelope> uploadCSVWithHttpInfo(String dtid, byte[] file) throws ApiException { com.squareup.okhttp.Call call = uploadCSVValidateBeforeCall(dtid, file, null, null); Type localVarReturnType = new TypeToken<UploadIdEnvelope>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
Upload a CSV file related to the Device Type. Upload a CSV file related to the Device Type. @param dtid Device Type ID. (required) @param file Device Type ID. (required) @return ApiResponse&lt;UploadIdEnvelope&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public static ExceptionCallback ignore() { return new ExceptionCallback() { @Override public void exception(FailedEventInvocation invocation) { FailedEventInvocation.log(LOG, invocation); } }; }
The default {@link ExceptionCallback} which simply logs any failure but takes no further action. @return The callback.
public static ExceptionCallback stopOnError() { return new ExceptionCallback() { @Override public void exception(FailedEventInvocation invocation) { FailedEventInvocation.log(LOG, invocation); invocation.getEvent().setHandled(true); } }; }
The callback will set the Event's {@link Event#isHandled() handled} flag to <code>true</code> to gracefully stop the delegation process when an exception occurs. Like {@link #ignore()}, the exception will be logged. @return The callback.
public static ExceptionCallback failOnError() { return new ExceptionCallback() { @Override public void exception(FailedEventInvocation invocation) { throw new AbortionException(invocation.getException()); } }; }
The callback will convert the occurred exception into an {@link AbortionException} and then throw it. This stops the delegation process with delegating the exception to the dispatcher of the event. @return The callback.
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.
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.
public double[][] solve(double[][] B) { if (B.length != m) { throw new IllegalArgumentException("Matrix row dimensions must agree."); } if (!this.isNonsingular()) { throw new RuntimeException("Matrix is singular."); } // Copy right hand side with pivoting int nx = B[0].length; double[][] X = Matrix.Submatrix(B, piv, 0, nx - 1); // Solve L*Y = B(piv,:) for (int k = 0; k < n; k++) { for (int i = k + 1; i < n; i++) { for (int j = 0; j < nx; j++) { X[i][j] -= X[k][j] * LU[i][k]; } } } // Solve U*X = Y; for (int k = n - 1; k >= 0; k--) { for (int j = 0; j < nx; j++) { X[k][j] /= LU[k][k]; } for (int i = 0; i < k; i++) { for (int j = 0; j < nx; j++) { X[i][j] -= X[k][j] * LU[i][k]; } } } return X; }
Solve A*X = B @param B A Matrix with as many rows as A and any number of columns. @return X so that L*U*X = B(piv,:) @throws IllegalArgumentException Matrix row dimensions must agree. @throws RuntimeException Matrix is singular.
public static double[] getReal(ComplexNumber[] cn) { double[] n = new double[cn.length]; for (int i = 0; i < n.length; i++) { n[i] = cn[i].real; } return n; }
Get real part from the complex numbers. @param cn Complex numbers. @return Real part.
public static double[] getImaginary(ComplexNumber[] cn) { double[] n = new double[cn.length]; for (int i = 0; i < n.length; i++) { n[i] = cn[i].imaginary; } return n; }
Get imaginary part from the complex numbers. @param cn Complex numbers. @return Imaginary part.
public static double[][] getReal(ComplexNumber[][] cn) { double[][] n = new double[cn.length][cn[0].length]; for (int i = 0; i < n.length; i++) { for (int j = 0; j < n[0].length; j++) { n[i][j] = cn[i][j].real; } } return n; }
Get real part from the complex numbers. @param cn Complex numbers. @return Real part.
public static double[][] getImaginary(ComplexNumber[][] cn) { double[][] n = new double[cn.length][cn[0].length]; for (int i = 0; i < n.length; i++) { for (int j = 0; j < n[0].length; j++) { n[i][j] = cn[i][j].imaginary; } } return n; }
Get imaginary part from the complex numbers. @param cn Complex numbers. @return Imaginary part.
public static void Swap(ComplexNumber z1) { double t = z1.real; z1.real = z1.imaginary; z1.imaginary = t; }
Swap values between real and imaginary. @param z1 Complex number.
public static void Swap(ComplexNumber[] z) { for (int i = 0; i < z.length; i++) { z[i] = new ComplexNumber(z[i].imaginary, z[i].real); } }
Swap values between real and imaginary. @param z Complex number.
public static void Swap(ComplexNumber[][] z) { for (int i = 0; i < z.length; i++) { for (int j = 0; j < z[0].length; j++) { z[i][j] = new ComplexNumber(z[i][j].imaginary, z[i][j].real); } } }
Swap values between real and imaginary. @param z Complex number.
public static double[] Abs(ComplexNumber[] z) { double[] values = new double[z.length]; for (int i = 0; i < values.length; i++) { values[i] = z[i].getMagnitude(); } return values; }
Absolute value of complex number. @param z Complex Numbers. @return Absolute number.
public static double[][] Abs(ComplexNumber[][] z) { double[][] values = new double[z.length][z[0].length]; for (int i = 0; i < values.length; i++) { for (int j = 0; j < values[0].length; j++) { values[i][j] = z[i][j].getMagnitude(); } } return values; }
Absolute value of complex number. @param z Complex numbers. @return Absolute number.
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.
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.
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.
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.
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.
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.
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.
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.
public static ComplexNumber Divide(ComplexNumber z1, double scalar) { return new ComplexNumber(z1.real / scalar, z1.imaginary / scalar); }
Divides scalar value to a complex number. @param z1 Complex Number. @param scalar Scalar value. @return Returns new ComplexNumber instance containing the divide of specified complex number with the scalar value.
public void Divide(double scalar) { if (scalar == 0) { try { throw new ArithmeticException("Can not divide by zero."); } catch (Exception e) { e.printStackTrace(); } } this.real /= scalar; this.imaginary /= scalar; }
Divides scalar value to a complex number. @param scalar Scalar value.
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.
public static ComplexNumber Log(ComplexNumber z1) { ComplexNumber result = new ComplexNumber(); if ((z1.real > 0.0) && (z1.imaginary == 0.0)) { result.real = Math.log(z1.real); result.imaginary = 0.0; } else if (z1.real == 0.0) { if (z1.imaginary > 0.0) { result.real = Math.log(z1.imaginary); result.imaginary = Math.PI / 2.0; } else { result.real = Math.log(-(z1.imaginary)); result.imaginary = -Math.PI / 2.0; } } else { result.real = Math.log(z1.getMagnitude()); result.imaginary = Math.atan2(z1.imaginary, z1.real); } return result; }
Calculates natural (base <b>e</b>) logarithm of a complex number. @param z1 Complex Number instance. @return Returns new ComplexNumber instance containing the natural logarithm of the specified complex number.
public static ComplexNumber Exp(ComplexNumber z1) { ComplexNumber x, y; x = new ComplexNumber(Math.exp(z1.real), 0.0); y = new ComplexNumber(Math.cos(z1.imaginary), Math.sin(z1.imaginary)); return Multiply(x, y); }
Calculates exponent (e raised to the specified power) of a complex number. @param z1 A Complex Number instance. @return Returns new ComplexNumber instance containing the exponent of the specified complex number.
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.
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.
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.
public static IntPoint Add(IntPoint point1, IntPoint point2) { IntPoint result = new IntPoint(point1); result.Add(point2); return result; }
Adds values of two points. @param point1 IntPoint. @param point2 IntPoint. @return IntPoint that contains X and Y axis coordinate.
public static IntPoint Subtract(IntPoint point1, IntPoint point2) { IntPoint result = new IntPoint(point1); result.Subtract(point2); return result; }
Subtract values of two points. @param point1 IntPoint. @param point2 IntPoint. @return IntPoint that contains X and Y axis coordinate.
public static IntPoint Multiply(IntPoint point1, IntPoint point2) { IntPoint result = new IntPoint(point1); result.Multiply(point2); return result; }
Multiply values of two points. @param point1 IntPoint. @param point2 IntPoint. @return IntPoint that contains X and Y axis coordinate.
public static IntPoint Divide(IntPoint point1, IntPoint point2) { IntPoint result = new IntPoint(point1); result.Divide(point2); return result; }
Divides values of two points. @param point1 IntPoint. @param point2 IntPoint. @return IntPoint that contains X and Y axis coordinate.
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.
public double[][] solve(double[][] B) { if (B.length != m) { throw new IllegalArgumentException("Matrix row dimensions must agree."); } if (!this.isFullRank()) { throw new RuntimeException("Matrix is rank deficient."); } // Copy right hand side int nx = B[0].length; double[][] X = B.clone(); // compute Y = transpose(Q)*B for (int k = 0; k < n; k++) { for (int j = 0; j < nx; j++) { double s = 0.0; for (int i = k; i < m; i++) { s += QR[i][k] * X[i][j]; } s = -s / QR[k][k]; for (int i = k; i < m; i++) { X[i][j] += s * QR[i][k]; } } } // Solve R*X = Y; for (int k = n - 1; k >= 0; k--) { for (int j = 0; j < nx; j++) { X[k][j] /= Rdiag[k]; } for (int i = 0; i < k; i++) { for (int j = 0; j < nx; j++) { X[i][j] -= X[k][j] * QR[i][k]; } } } double[][] mat = new double[n][nx]; for (int i = 0; i < mat.length; i++) { for (int j = 0; j < mat[0].length; j++) { mat[i][j] = X[i][j]; } } return mat; }
Least squares solution of A*X = B @param B A Matrix with as many rows as A and any number of columns. @return X that minimizes the two norm of Q*R*X-B. @throws IllegalArgumentException Matrix row dimensions must agree. @throws RuntimeException Matrix is rank deficient.
@Override public int nextInt() { long oldState = state; state = oldState * MULTIPLIER + inc; int xorShifted = (int) (((oldState >>> 18) ^ oldState) >>> 27); int rot = (int) (oldState >>> 59); return Integer.rotateRight(xorShifted, rot); }
Returns the next pseudorandom, approximately uniformly distributed {@code int} value from this random number generator's sequence. The general contract of {@code nextInt} is that one {@code int} value is pseudorandomly generated and returned. All 2<font size="-1"><sup>32 </sup></font> possible {@code int} values are produced with (approximately) equal probability. @see java.util.Random#nextInt()
@Override public int nextInt(int n) { if (n <= 0) { throw new IllegalArgumentException("n must be positive"); } // the special treatment of powers of 2 as in Random.nextInt(int) shouldn't be necessary int bits, val; do { bits = nextInt() >>> 1; val = bits % n; } while (bits - val + (n - 1) < 0); return val; }
Returns the next pseudorandom, approximately uniformly distributed {@code int} value between 0 (inclusive) and {@code n} (exclusive). @see java.util.Random#nextInt(int)
public double nextGaussian() { // See Knuth, ACP, Section 3.4.1 Algorithm C. if (haveNextNextGaussian) { haveNextNextGaussian = false; return nextNextGaussian; } else { double v1, v2, s; do { v1 = 2 * nextDouble() - 1; // between -1 and 1 v2 = 2 * nextDouble() - 1; // between -1 and 1 s = v1 * v1 + v2 * v2; } while (s >= 1 || s == 0); double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s) / s); nextNextGaussian = v2 * multiplier; haveNextNextGaussian = true; return v1 * multiplier; } }
Returns the next pseudorandom, Gaussian ("normally") distributed {@code double} value with mean {@code 0.0} and standard deviation {@code 1.0} from this random number generator's sequence. @see java.util.Random#nextGaussian()
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.
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.
public static double Kurtosis(int[] values){ double mean = Mean(values); double std = StdDev(values, mean); return Kurtosis(values, mean, std); }
Calculate Kurtosis value. @param values Values. @return Returns kurtosis value of the specified histogram array.
public static double Kurtosis(int[] values, double mean, double stdDeviation){ double n = 0; for (int i = 0; i < values.length; i++) n += values[i]; double part1 = n * (n + 1); part1 /= ((n - 1) * (n - 2) * (n - 3)); double part2 = 0; for (int i = 0; i < values.length; i++) { part2 += Math.pow((i - mean) / stdDeviation, 4) * values[i]; } double part3 = 3 * Math.pow((n - 1), 2); part3 /= (n - 2) * (n - 3); return part1 * part2 - part3; }
Calculate Kurtosis value. @param values Values. @param mean Specified mean. @param stdDeviation Specified standard deviation. @return Returns kurtosis value of the specified histogram array.
public static double Mean( int[] values ) { int hits; long total = 0; double mean = 0; // for all values for ( int i = 0, n = values.length; i < n; i++ ) { hits = values[i]; // accumulate mean mean += i * hits; // accumalate total total += hits; } return ( total == 0 ) ? 0 : mean / total; }
Calculate Mean value. @param values Values. @return Mean.
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.
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.
public static double Skewness(int[] values){ double mean = Mean(values); double std = StdDev(values, mean); return Skewness(values, mean, std); }
Calculate Skewness value. @param values Values. @return Returns skewness value of the specified histogram array.
public static double Skewness(int[] values, double mean, double stdDeviation){ double n = 0; for (int i = 0; i < values.length; i++) n += values[i]; double part1 = n / (n - 1) * (n - 2); double part2 = 0; for (int i = 0; i < values.length; i++) { part2 += Math.pow((i - mean) / stdDeviation, 3) * values[i]; } return part1 * part2; }
Calculate Skewness value. @param values Values. @param mean Specified mean. @param stdDeviation Specified standard deviation. @return Returns skewness value of the specified histogram array.
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.
@SuppressWarnings("unchecked") public <E> Optional<E> getValue(String key) { if (this.properties == null) { return Optional.empty(); } return Optional.ofNullable((E) getProperties().get(key)); }
Returns a value that has been stored using {@link #setValue(String, Object)}. As this method is generic, the value will automatically be casted to the target type of the expression in which this method is called. So this method has to be used with caution in respect to type safety. @param <E> Type of the resulting value. @param key The key of the value to retrieve. @return The value or an empty optional if the value does not exist. @since 3.0.0 @see #getValueAs(String, Class)
public <E> Optional<E> getValueAs(String key, Class<E> type) { if (this.properties == null) { return Optional.empty(); } return Optional.ofNullable(type.cast(getProperties().get(key))); }
Returns a value that has been stored using {@link #setValue(String, Object)}. The value will be casted to the given type. @param <E> Type of the resulting value. @param key The key of the value to retrieve. @param type The type that the value will be casted to. @return The value or an empty optional if the value does not exist. @see #getValue(String)
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.
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.
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.
@Override public ImageSource apply(ImageSource source) { int width = source.getWidth(); int height = source.getHeight(); int[][] result = new int[height][width]; if (source.isGrayscale()) { for (int i = 0; i < height; i++) { int iMin = Math.max(0, i - blockRadius); int iMax = Math.min(height, i + blockRadius + 1); int h = iMax - iMin; int jMin = Math.max(0, -blockRadius); int jMax = Math.min(width - 1, blockRadius); int[] hist = new int[bins + 1]; int[] clippedHist = new int[bins + 1]; for (int k = iMin; k < iMax; k++) { for (int l = jMin; l < jMax; l++) { ++hist[roundPositive(source.getGray(l, k) / 255.0f * bins)]; } } for (int j = 0; j < width; j++) { int v = roundPositive(source.getGray(j, i) / 255.0f * bins); int xMin = Math.max(0, j - blockRadius); int xMax = j + blockRadius + 1; int w = Math.min(width, xMax) - xMin; int n = h * w; int limit = (int) (slope * n / bins + 0.5f); /* remove left behind values from histogram */ if (xMin > 0) { int xMin1 = xMin - 1; for (int yi = iMin; yi < iMax; ++yi) { --hist[roundPositive(source.getGray(xMin1, yi) / 255.0f * bins)]; } } /* add newly included values to histogram */ if (xMax <= width) { int xMax1 = xMax - 1; for (int yi = iMin; yi < iMax; ++yi) { ++hist[roundPositive(source.getGray(xMax1, yi) / 255.0f * bins)]; } } System.arraycopy(hist, 0, clippedHist, 0, hist.length); int clippedEntries = 0, clippedEntriesBefore; do { clippedEntriesBefore = clippedEntries; clippedEntries = 0; for (int z = 0; z <= bins; ++z) { int d = clippedHist[z] - limit; if (d > 0) { clippedEntries += d; clippedHist[z] = limit; } } int d = clippedEntries / (bins + 1); int m = clippedEntries % (bins + 1); for (int z = 0; z <= bins; ++z) { clippedHist[z] += d; } if (m != 0) { int s = bins / m; for (int z = 0; z <= bins; z += s) { ++clippedHist[z]; } } } while (clippedEntries != clippedEntriesBefore); /* build cdf of clipped histogram */ int hMin = bins; for (int z = 0; z < hMin; ++z) { if (clippedHist[z] != 0) hMin = z; } int cdf = 0; for (int z = hMin; z <= v; ++z) { cdf += clippedHist[z]; } int cdfMax = cdf; for (int z = v + 1; z <= bins; ++z) { cdfMax += clippedHist[z]; } int cdfMin = clippedHist[hMin]; result[i][j] = roundPositive((cdf - cdfMin) / (float) (cdfMax - cdfMin) * 255.0f); } for (int a = 0; a < width; a++) { source.setGray(a, i, result[i][a]); } } } else { MatrixSource gray = new MatrixSource(source); Grayscale gs = new Grayscale(algorithm); // It is not OneBandSource gs.apply(gray); for (int i = 0; i < height; i++) { int iMin = Math.max(0, i - blockRadius); int iMax = Math.min(height, i + blockRadius + 1); int h = iMax - iMin; int jMin = Math.max(0, -blockRadius); int jMax = Math.min(width - 1, blockRadius); int[] hist = new int[bins + 1]; int[] clippedHist = new int[bins + 1]; for (int k = iMin; k < iMax; k++) { for (int l = jMin; l < jMax; l++) { ++hist[roundPositive(gray.getGray(l, k) / 255.0f * bins)]; } } for (int j = 0; j < width; j++) { int v = roundPositive(gray.getGray(j, i) / 255.0f * bins); int xMin = Math.max(0, j - blockRadius); int xMax = j + blockRadius + 1; int w = Math.min(width, xMax) - xMin; int n = h * w; int limit = (int) (slope * n / bins + 0.5f); /* remove left behind values from histogram */ if (xMin > 0) { int xMin1 = xMin - 1; for (int yi = iMin; yi < iMax; ++yi) { --hist[roundPositive(gray.getGray(xMin1, yi) / 255.0f * bins)]; } } /* add newly included values to histogram */ if (xMax <= width) { int xMax1 = xMax - 1; for (int yi = iMin; yi < iMax; ++yi) { ++hist[roundPositive(gray.getGray(xMax1, yi) / 255.0f * bins)]; } } System.arraycopy(hist, 0, clippedHist, 0, hist.length); int clippedEntries = 0, clippedEntriesBefore; do { clippedEntriesBefore = clippedEntries; clippedEntries = 0; for (int z = 0; z <= bins; ++z) { int d = clippedHist[z] - limit; if (d > 0) { clippedEntries += d; clippedHist[z] = limit; } } int d = clippedEntries / (bins + 1); int m = clippedEntries % (bins + 1); for (int z = 0; z <= bins; ++z) clippedHist[z] += d; if (m != 0) { int s = bins / m; for (int z = 0; z <= bins; z += s) ++clippedHist[z]; } } while (clippedEntries != clippedEntriesBefore); /* build cdf of clipped histogram */ int hMin = bins; for (int z = 0; z < hMin; ++z) { if (clippedHist[z] != 0) hMin = z; } int cdf = 0; for (int z = hMin; z <= v; ++z) { cdf += clippedHist[z]; } int cdfMax = cdf; for (int z = v + 1; z <= bins; ++z) { cdfMax += clippedHist[z]; } int cdfMin = clippedHist[hMin]; result[i][j] = roundPositive((cdf - cdfMin) / (float) (cdfMax - cdfMin) * 255.0f); } for (int a = 0; a < width; a++) { float s = (float) result[i][a] / (float) gray.getGray(a, i); float r = ColorHelper.clamp(roundPositive(s * source.getR(a, i))); float g = ColorHelper.clamp(roundPositive(s * source.getG(a, i))); float b = ColorHelper.clamp(roundPositive(s * source.getB(a, i))); int rgb = ColorHelper.getRGB((int) r, (int) g, (int) b); source.setRGB(a, i, rgb); } } } return source; }
This effect deals with OneBandSource and Binary MatrixSource @param source @return image
@Parameters public static final Collection<Object[]> getParameters() { return Arrays.asList( new Object[] { (Function<ListenerStore, ? extends EventProvider>) SequentialEventProvider::new, (Supplier<ListenerStore>) DefaultListenerStore::create }, new Object[] { (Function<ListenerStore, ? extends EventProvider>) SequentialEventProvider::new, (Supplier<ListenerStore>) PriorityListenerStore::create } ); }
Parameterizes the test instances. @return Collection of parameters for the constructor of {@link EventProviderTestBase}.
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.
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.
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.
public DeviceSharingId createShareForDevice(String deviceId, DeviceShareInfo deviceShareInfo) throws ApiException { ApiResponse<DeviceSharingId> resp = createShareForDeviceWithHttpInfo(deviceId, deviceShareInfo); return resp.getData(); }
Share a device Share a device @param deviceId Device ID. (required) @param deviceShareInfo Device object that needs to be added (required) @return DeviceSharingId @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<DeviceSharingId> createShareForDeviceWithHttpInfo(String deviceId, DeviceShareInfo deviceShareInfo) throws ApiException { com.squareup.okhttp.Call call = createShareForDeviceValidateBeforeCall(deviceId, deviceShareInfo, null, null); Type localVarReturnType = new TypeToken<DeviceSharingId>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
Share a device Share a device @param deviceId Device ID. (required) @param deviceShareInfo Device object that needs to be added (required) @return ApiResponse&lt;DeviceSharingId&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public DeviceSharingId deleteSharingForDevice(String deviceId, String shareId) throws ApiException { ApiResponse<DeviceSharingId> resp = deleteSharingForDeviceWithHttpInfo(deviceId, shareId); return resp.getData(); }
Delete specific share of the given device id Delete specific share of the given device id @param deviceId Device ID. (required) @param shareId Share ID. (required) @return DeviceSharingId @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<DeviceSharingId> deleteSharingForDeviceWithHttpInfo(String deviceId, String shareId) throws ApiException { com.squareup.okhttp.Call call = deleteSharingForDeviceValidateBeforeCall(deviceId, shareId, null, null); Type localVarReturnType = new TypeToken<DeviceSharingId>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
Delete specific share of the given device id Delete specific share of the given device id @param deviceId Device ID. (required) @param shareId Share ID. (required) @return ApiResponse&lt;DeviceSharingId&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public DeviceSharingEnvelope getAllSharesForDevice(String deviceId, Integer count, Integer offset) throws ApiException { ApiResponse<DeviceSharingEnvelope> resp = getAllSharesForDeviceWithHttpInfo(deviceId, count, offset); return resp.getData(); }
List all shares for the given device id List all shares for the given device id @param deviceId Device ID. (required) @param count Desired count of items in the result set. (optional) @param offset Offset for pagination. (optional) @return DeviceSharingEnvelope @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<DeviceSharingEnvelope> getAllSharesForDeviceWithHttpInfo(String deviceId, Integer count, Integer offset) throws ApiException { com.squareup.okhttp.Call call = getAllSharesForDeviceValidateBeforeCall(deviceId, count, offset, null, null); Type localVarReturnType = new TypeToken<DeviceSharingEnvelope>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
List all shares for the given device id List all shares for the given device id @param deviceId Device ID. (required) @param count Desired count of items in the result set. (optional) @param offset Offset for pagination. (optional) @return ApiResponse&lt;DeviceSharingEnvelope&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public DeviceSharing getSharingForDevice(String deviceId, String shareId) throws ApiException { ApiResponse<DeviceSharing> resp = getSharingForDeviceWithHttpInfo(deviceId, shareId); return resp.getData(); }
Get specific share of the given device id Get specific share of the given device id @param deviceId Device ID. (required) @param shareId Share ID. (required) @return DeviceSharing @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public ApiResponse<DeviceSharing> getSharingForDeviceWithHttpInfo(String deviceId, String shareId) throws ApiException { com.squareup.okhttp.Call call = getSharingForDeviceValidateBeforeCall(deviceId, shareId, null, null); Type localVarReturnType = new TypeToken<DeviceSharing>(){}.getType(); return apiClient.execute(call, localVarReturnType); }
Get specific share of the given device id Get specific share of the given device id @param deviceId Device ID. (required) @param shareId Share ID. (required) @return ApiResponse&lt;DeviceSharing&gt; @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
public static float Mean(ImageSource fastBitmap, int startX, int startY, int width, int height) { float mean = 0; if (fastBitmap.isGrayscale()) { for (int i = startX; i < height; i++) { for (int j = startY; j < width; j++) { mean += fastBitmap.getRGB(j, i); } } return mean / (width * height); } else { throw new IllegalArgumentException("ImageStatistics: Only compute mean in grayscale images."); } }
Calculate Mean value. @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 Mean.
public static float Variance(ImageSource fastBitmap, float mean) { return Variance(fastBitmap, mean, 0, 0, fastBitmap.getWidth(), fastBitmap.getHeight()); }
Calculate Variance. @param fastBitmap Image to be processed. @param mean Mean. @return Variance.
public static float Variance(ImageSource fastBitmap, float mean, int startX, int startY, int width, int height) { float sum = 0; if (fastBitmap.isGrayscale()) { for (int i = startX; i < height; i++) { for (int j = startY; j < width; j++) { sum += Math.pow(fastBitmap.getRGB(j, i) - mean, 2); } } return sum / (float) ((width * height) - 1); } else { throw new IllegalArgumentException("ImageStatistics: Only compute variance in grayscale images."); } }
Calculate Variance. @param fastBitmap Image to be processed. @param mean Mean. @param startX Initial X axis coordinate. @param startY Initial Y axis coordinate. @param width Width. @param height Height. @return Variance.
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.
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.
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.
public static double BrayCurtis(double[] p, double[] q) { double sumP, sumN; sumP = sumN = 0; for (int i = 0; i < p.length; i++) { sumN += Math.abs(p[i] - q[i]); sumP += Math.abs(p[i] + q[i]); } return sumN / sumP; }
Gets the Bray Curtis distance between two points. @param p A point in space. @param q A point in space. @return The Bray Curtis distance between x and y.
public static double BrayCurtis(double x1, double y1, double x2, double y2) { double sumN = Math.abs(x1 - x2) + Math.abs(y1 - y2); double sumP = Math.abs(x1 + x2) + Math.abs(y1 + y2); return sumN / sumP; }
Gets the Bray Curtis distance between two points. @param x1 X1 axis coordinate. @param y1 Y1 axis coordinate. @param x2 X2 axis coordinate. @param y2 X2 axis coordinate. @return The Bray Curtis distance between x and y.
public static double BrayCurtis(IntPoint p, IntPoint q) { return BrayCurtis(p.x, p.y, q.x, q.y); }
Gets the Bray Curtis distance between two points. @param p IntPoint with X and Y axis coordinates. @param q IntPoint with X and Y axis coordinates. @return The Bray Curtis distance between x and y.
public static double Canberra(double[] p, double[] q) { double distance = 0; for (int i = 0; i < p.length; i++) { distance += Math.abs(p[i] - q[i]) / (Math.abs(p[i]) + Math.abs(q[i])); } return distance; }
Gets the Canberra distance between two points. @param p A point in space. @param q A point in space. @return The Canberra distance between x and y.
public static double Canberra(double x1, double y1, double x2, double y2) { double distance; distance = Math.abs(x1 - x2) / (Math.abs(x1) + Math.abs(x2)); distance += Math.abs(y1 - y2) / (Math.abs(y1) + Math.abs(y2)); return distance; }
Gets the Canberra distance between two points. @param x1 X1 axis coordinate. @param y1 Y1 axis coordinate. @param x2 X2 axis coordinate. @param y2 Y2 axis coordinate. @return The Canberra distance between x and y.
public static double Canberra(IntPoint p, IntPoint q) { return Canberra(p.x, p.y, q.x, q.y); }
Gets the Canberra distance between two points. @param p IntPoint with X and Y axis coordinates. @param q IntPoint with X and Y axis coordinates. @return The Canberra distance between x and y.
public static double Chebyshev(double[] p, double[] q) { double max = Math.abs(p[0] - q[0]); for (int i = 1; i < p.length; i++) { double abs = Math.abs(p[i] - q[i]); if (abs > max) max = abs; } return max; }
Gets the Chebyshev distance between two points. @param p A point in space. @param q A point in space. @return The Chebyshev distance between x and y.
public static double Chebyshev(double x1, double y1, double x2, double y2) { double max = Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)); return max; }
Gets the Chebyshev distance between two points. @param x1 X1 axis coordinate. @param y1 Y1 axis coordinate. @param x2 X2 axis coordinate. @param y2 Y2 axis coordinate. @return The Chebyshev distance between x and y.
public static double Chebyshev(IntPoint p, IntPoint q) { return Chebyshev(p.x, p.y, q.x, q.y); }
Gets the Chebyshev distance between two points. @param p IntPoint with X and Y axis coordinates. @param q IntPoint with X and Y axis coordinates. @return The Chebyshev distance between x and y.
public static double Chessboard(double[] x, double[] y) { double d = 0; for (int i = 0; i < x.length; i++) { d = Math.max(d, x[i] - y[i]); } return d; }
Gets the Chessboard distance between two points. @param x A point in space. @param y A point in space. @return The Chessboard distance between x and y.
public static double Chessboard(double x1, double y1, double x2, double y2) { double dx = Math.abs(x1 - x2); double dy = Math.abs(y1 - y2); return Math.max(dx, dy); }
Gets the Chessboard distance between two points. @param x1 X1 axis coordinate. @param y1 Y1 axis coordinate. @param x2 X2 axis coordinate. @param y2 Y2 axis coordinate. @return The Chessboard distance between x and y.
public static double Chessboard(IntPoint p, IntPoint q) { return Chessboard(p.x, p.y, q.x, q.y); }
Gets the Chessboard distance between two points. @param p IntPoint with X and Y axis coordinates. @param q IntPoint with X and Y axis coordinates. @return The Chessboard distance between x and y.