iterator2 = matrix2.iterator();
+ double res = 0;
+ while (iterator1.hasNext() && iterator2.hasNext()) {
+ res += getTrueDistance(iterator1.next(), iterator2.next());
+ }
+ return res;
+ }
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/ChebyshevDistance.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/ChebyshevDistance.java
index 7b1433f..08f551d 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/ChebyshevDistance.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/ChebyshevDistance.java
@@ -9,6 +9,8 @@
import zhao.algorithmMagic.operands.coordinate.Coordinate;
import zhao.algorithmMagic.operands.coordinate.FloatingPointCoordinates;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinates;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute;
@@ -322,4 +324,56 @@ public double getTrueDistance(IntegerConsanguinityRoute integerConsanguinityRout
public double getTrueDistance(IntegerConsanguinityRoute2D integerConsanguinityRoute2D) {
return getTrueDistance(integerConsanguinityRoute2D.getStartingCoordinate().toArray(), integerConsanguinityRoute2D.getEndPointCoordinate().toArray());
}
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param integerMatrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(IntegerMatrix integerMatrix1, IntegerMatrix matrix2) {
+ int res = 0;
+ for (int[] ints : integerMatrix1.diff(matrix2)) {
+ for (int anInt : ints) {
+ if (anInt > res) res = anInt;
+ }
+ }
+ return res;
+ }
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(DoubleMatrix matrix1, DoubleMatrix matrix2) {
+ double res = 0;
+ for (double[] ints : matrix1.diff(matrix2)) {
+ for (double anInt : ints) {
+ if (anInt > res) res = anInt;
+ }
+ }
+ return res;
+ }
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/CosineDistance.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/CosineDistance.java
index 563ebd4..a9243bf 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/CosineDistance.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/CosineDistance.java
@@ -5,6 +5,8 @@
import zhao.algorithmMagic.algorithm.OperationAlgorithm;
import zhao.algorithmMagic.algorithm.OperationAlgorithmManager;
import zhao.algorithmMagic.exception.TargetNotRealizedException;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute;
@@ -273,4 +275,44 @@ public double getTrueDistance(IntegerConsanguinityRoute integerConsanguinityRout
public double getTrueDistance(IntegerConsanguinityRoute2D integerConsanguinityRoute2D) {
return getTrueDistance(integerConsanguinityRoute2D.getStartingCoordinate().toArray(), integerConsanguinityRoute2D.getEndPointCoordinate().toArray());
}
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param integerMatrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(IntegerMatrix integerMatrix1, IntegerMatrix matrix2) {
+ return integerMatrix1.innerProduct(matrix2) / (double) (integerMatrix1.moduleLength() * matrix2.moduleLength());
+ }
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(DoubleMatrix matrix1, DoubleMatrix matrix2) {
+ return matrix1.innerProduct(matrix2) / (matrix1.moduleLength() * matrix2.moduleLength());
+ }
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/DistanceAlgorithm.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/DistanceAlgorithm.java
index cd2b46a..e9ed0fe 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/DistanceAlgorithm.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/DistanceAlgorithm.java
@@ -1,6 +1,10 @@
package zhao.algorithmMagic.algorithm.distanceAlgorithm;
import zhao.algorithmMagic.algorithm.OperationAlgorithm;
+import zhao.algorithmMagic.exception.OperatorOperationException;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
+import zhao.algorithmMagic.operands.matrix.Matrix;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute;
@@ -13,6 +17,31 @@
*/
public interface DistanceAlgorithm extends OperationAlgorithm {
+ /**
+ * 典漲霈∠蝞瘜蝏隞嗡葉嚗賢舀拚萄笆鞊∠餈蝞嚗雿臬刻蝞銋閬撖寧拚萎葉唳株銵銝銝芣伐蝖桐嗡隡霂胯
+ *
+ * In the metric calculation algorithm component, operations on matrix objects can be supported, but before operations, it is necessary to check the data in the matrix to ensure that no errors occur.
+ *
+ * @param Matrix1 閬鋡怨恣蝞拚萄笆鞊∴敺璉亦拚萄笆鞊∼
+ *
+ * The matrix object to be calculated and the matrix object to be checked.
+ * @param Matrix2 閬鋡怨恣蝞拚萄笆鞊∴敺璉亦拚萄笆鞊∼
+ *
+ * The matrix object to be calculated and the matrix object to be checked.
+ */
+ static void checkMat(Matrix, ?, ?, ?, ?> Matrix1, Matrix, ?, ?, ?, ?> Matrix2) {
+ check(Matrix1.getRowCount(), Matrix1.getColCount(), Matrix2.getRowCount(), Matrix2.getColCount());
+ }
+
+ static void check(int rowCount, int colCount, int rowCount3, int colCount3) {
+ if (rowCount != rowCount3)
+ throw new OperatorOperationException("拚萄笆鞊∩葉銵圈銝銝湛銝航恣蝞\nThe number of rows in the matrix object is inconsistent and cannot be calculated.ERROR => row1 = " +
+ rowCount + "\trow2 = " + rowCount3);
+ if (colCount != colCount3)
+ throw new OperatorOperationException("拚萄笆鞊∩葉圈銝銝湛銝航恣蝞\nThe number of cols in the matrix object is inconsistent and cannot be calculated.ERROR => col1 = " +
+ colCount + "\tcol2 = " + colCount3);
+ }
+
/**
* 霈∠銝銝芾楝蝥輻韏瑕嫣蝏甇Y寧摰頝蝳颯瑚頝蝳餃堆閬冽仿蝞瘜摰啁獢
*
@@ -82,4 +111,38 @@ public interface DistanceAlgorithm extends OperationAlgorithm {
* @return ...
*/
double getTrueDistance(IntegerConsanguinityRoute2D integerConsanguinityRoute2D);
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ double getTrueDistance(IntegerMatrix matrix1, IntegerMatrix matrix2);
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ double getTrueDistance(DoubleMatrix matrix1, DoubleMatrix matrix2);
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/EuclideanMetric.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/EuclideanMetric.java
index 94f5388..c7bbe1a 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/EuclideanMetric.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/EuclideanMetric.java
@@ -9,6 +9,8 @@
import zhao.algorithmMagic.operands.coordinate.Coordinate;
import zhao.algorithmMagic.operands.coordinate.FloatingPointCoordinates;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinates;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute;
@@ -332,6 +334,58 @@ public double getTrueDistance(IntegerConsanguinityRoute2D integerConsanguinityRo
return getTrueDistance(integerConsanguinityRoute2D.getStartingCoordinate().toArray(), integerConsanguinityRoute2D.getEndPointCoordinate().toArray());
}
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param integerMatrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(IntegerMatrix integerMatrix1, IntegerMatrix matrix2) {
+ int res = 0;
+ for (int[] ints : integerMatrix1.diff(matrix2)) {
+ for (int anInt : ints) {
+ res += ASMath.Power2(anInt);
+ }
+ }
+ return Math.sqrt(res);
+ }
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(DoubleMatrix matrix1, DoubleMatrix matrix2) {
+ double res = 0;
+ for (double[] ints : matrix1.diff(matrix2)) {
+ for (double anInt : ints) {
+ res += ASMath.Power2(anInt);
+ }
+ }
+ return Math.sqrt(res);
+ }
+
/**
* 霈∠頝蝳餃寧頝蝳颯
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/HausdorffDistance.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/HausdorffDistance.java
index e55ebec..2952d59 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/HausdorffDistance.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/HausdorffDistance.java
@@ -9,11 +9,14 @@
import zhao.algorithmMagic.operands.coordinate.Coordinate;
import zhao.algorithmMagic.operands.coordinate.FloatingPointCoordinates;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinates;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute;
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute2D;
import zhao.algorithmMagic.utils.ASClass;
+import zhao.algorithmMagic.utils.ASMath;
import java.util.HashMap;
@@ -230,4 +233,74 @@ public double getTrueDistance(IntegerConsanguinityRoute integerConsanguinityRout
public double getTrueDistance(IntegerConsanguinityRoute2D integerConsanguinityRoute2D) {
return getTrueDistance(integerConsanguinityRoute2D.getStartingCoordinate().toArray(), integerConsanguinityRoute2D.getEndPointCoordinate().toArray());
}
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param integerMatrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(IntegerMatrix integerMatrix1, IntegerMatrix matrix2) {
+ DistanceAlgorithm.checkMat(integerMatrix1, matrix2);
+ int[][] mat2 = matrix2.toArrays();
+ int[] res = new int[integerMatrix1.getNumberOfDimensions()];
+ for (int[] ints : integerMatrix1) {
+ for (int anInt : ints) {
+ // 撠 1 拚萎葉嫣 2 拚萎葉寧頝蝳餌憭批潸恣蝞箸
+ int max = 0;
+ for (int[] ints1 : mat2) {
+ for (int i : ints1) {
+ max = Math.max(anInt - i, max);
+ }
+ }
+ }
+ }
+ // 瑕 res 銝剔憭扳啣澆僎餈
+ return res[ASMath.findMaxIndex(res)];
+ }
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(DoubleMatrix matrix1, DoubleMatrix matrix2) {
+ DistanceAlgorithm.checkMat(matrix1, matrix2);
+ double[][] mat2 = matrix2.toArrays();
+ double[] res = new double[matrix1.getNumberOfDimensions()];
+ for (double[] ints : matrix1) {
+ for (double anInt : ints) {
+ // 撠 1 拚萎葉嫣 2 拚萎葉寧頝蝳餌憭批潸恣蝞箸
+ double max = 0;
+ for (double[] ints1 : mat2) {
+ for (double i : ints1) {
+ max = Math.max(anInt - i, max);
+ }
+ }
+ }
+ }
+ // 瑕 res 銝剔憭扳啣澆僎餈
+ return res[ASMath.findMaxIndex(res)];
+ }
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/ManhattanDistance.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/ManhattanDistance.java
index 71b8270..6f86cfb 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/ManhattanDistance.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/ManhattanDistance.java
@@ -6,6 +6,8 @@
import zhao.algorithmMagic.algorithm.OperationAlgorithmManager;
import zhao.algorithmMagic.exception.TargetNotRealizedException;
import zhao.algorithmMagic.operands.coordinate.*;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute;
@@ -329,6 +331,58 @@ public double getTrueDistance(IntegerConsanguinityRoute2D integerConsanguinityRo
return getTrueDistance(integerConsanguinityRoute2D.getStartingCoordinate().toArray(), integerConsanguinityRoute2D.getEndPointCoordinate().toArray());
}
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param integerMatrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(IntegerMatrix integerMatrix1, IntegerMatrix matrix2) {
+ int res = 0;
+ for (int[] ints : integerMatrix1.diff(matrix2)) {
+ for (int anInt : ints) {
+ res += ASMath.absoluteValue(anInt);
+ }
+ }
+ return res;
+ }
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(DoubleMatrix matrix1, DoubleMatrix matrix2) {
+ double res = 0;
+ for (double[] ints : matrix1.diff(matrix2)) {
+ for (double anInt : ints) {
+ res += ASMath.absoluteValue(anInt);
+ }
+ }
+ return res;
+ }
+
/**
* 霈∠頝蝳餃寧頝蝳颯
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/MinkowskiDistance.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/MinkowskiDistance.java
index 2491248..7034066 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/MinkowskiDistance.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/MinkowskiDistance.java
@@ -6,6 +6,8 @@
import zhao.algorithmMagic.algorithm.OperationAlgorithmManager;
import zhao.algorithmMagic.exception.TargetNotRealizedException;
import zhao.algorithmMagic.operands.coordinate.*;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute;
@@ -339,6 +341,60 @@ public double getTrueDistance(IntegerConsanguinityRoute2D integerConsanguinityRo
return getTrueDistance(integerConsanguinityRoute2D.getStartingCoordinate().toArray(), integerConsanguinityRoute2D.getEndPointCoordinate().toArray());
}
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(IntegerMatrix matrix1, IntegerMatrix matrix2) {
+ int res = 0;
+ int $P = get$P();
+ for (int[] ints : matrix1.diff(matrix2)) {
+ for (int anInt : ints) {
+ res += Math.pow(anInt, $P);
+ }
+ }
+ return res;
+ }
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(DoubleMatrix matrix1, DoubleMatrix matrix2) {
+ int res = 0;
+ int $P = get$P();
+ for (double[] ints : matrix1.diff(matrix2)) {
+ for (double anInt : ints) {
+ res += Math.pow(anInt, $P);
+ }
+ }
+ return res;
+ }
+
/**
* 霈∠頝蝳餃寧頝蝳颯
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/StandardizedEuclideanDistance.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/StandardizedEuclideanDistance.java
index acbe5cf..05f83f0 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/StandardizedEuclideanDistance.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/distanceAlgorithm/StandardizedEuclideanDistance.java
@@ -4,30 +4,22 @@
import zhao.algorithmMagic.algorithm.OperationAlgorithmManager;
import zhao.algorithmMagic.algorithm.normalization.Z_ScoreNormalization;
import zhao.algorithmMagic.exception.TargetNotRealizedException;
-import zhao.algorithmMagic.operands.coordinate.*;
+import zhao.algorithmMagic.operands.coordinate.DoubleCoordinateMany;
+import zhao.algorithmMagic.operands.coordinate.FloatingPointCoordinates;
+import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateMany;
+import zhao.algorithmMagic.operands.coordinate.IntegerCoordinates;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
import zhao.algorithmMagic.utils.ASClass;
-import zhao.algorithmMagic.utils.DependentAlgorithmNameLibrary;
/**
* Java蝐颱 2022/10/13 10:30:50 撱
*
* 甈批敺摨阡嚗撠瘥銝銝芰輕摨衣餈銵嚗嗅餈銵甈批敺霈∠
*
- * @param 祉掩銝剖銝餈蝞湔啣蝐餃嚗券閬冽迨蝐餌摰霂亦掩臭誑餈蝞游耦
- *
- * The type of integer coordinates involved in the operation in this class, you need to specify the integer coordinates that this class can operate on in this class.
- * @param 祉掩銝剖銝餈蝞瘚桃孵蝐餃嚗券閬冽迨蝐餌摰霂亦掩臭誑餈蝞瘚桃孵
- *
- * The type of floating-point coordinates involved in the operation in this class. You need to specify the floating-point coordinates that this class can operate on.
* @author LingYuZhao
*/
-public class StandardizedEuclideanDistance & Coordinate, D extends FloatingPointCoordinates>> extends EuclideanMetric {
-
- private final EuclideanMetric euclideanMetric = EuclideanMetric.getInstance(DependentAlgorithmNameLibrary.EUCLIDEAN_METRIC_NAME);
-
- protected StandardizedEuclideanDistance() {
- super();
- }
+public class StandardizedEuclideanDistance extends EuclideanMetric {
protected StandardizedEuclideanDistance(String algorithmName) {
super(algorithmName);
@@ -37,40 +29,25 @@ protected StandardizedEuclideanDistance(String algorithmName) {
* 瑕啗砲蝞瘜蝐餃笆鞊∴
*
* @param Name 霂亦瘜蝘
- * @param 霂亦瘜冽亙游耦臭銋唳桃掩
- *
- * What data type is the integer coordinate used by this algorithm?
- * @param
霂亦瘜冽亙瘚桃孵臭銋唳桃掩
* @return 蝞瘜蝐餃笆鞊
* @throws TargetNotRealizedException 敶其亦蝞瘜蝘啣笆摨蝏隞嗡質◤嗅隡箏撣
*/
- public static & Coordinate, DD extends FloatingPointCoordinates>> StandardizedEuclideanDistance getInstance2(String Name) {
+ public static StandardizedEuclideanDistance getInstance2(String Name) {
if (OperationAlgorithmManager.containsAlgorithmName(Name)) {
OperationAlgorithm operationAlgorithm = OperationAlgorithmManager.getInstance().get(Name);
- if (operationAlgorithm instanceof StandardizedEuclideanDistance, ?>) {
+ if (operationAlgorithm instanceof StandardizedEuclideanDistance) {
return ASClass.transform(operationAlgorithm);
} else {
throw new TargetNotRealizedException("冽[" + Name + "]蝞瘜鋡急曉唬嚗雿臬銝撅鈭StandardizedEuclideanDistance蝐餃嚗霂瑟其蛹餈銝芰瘜啣銋銝銝芸蝘啜\n" +
"The [" + Name + "] algorithm you extracted has been found, but it does not belong to the StandardizedEuclideanDistance type. Please redefine a name for this algorithm.");
}
} else {
- StandardizedEuclideanDistance standardizedEuclideanDistance = new StandardizedEuclideanDistance<>(Name);
+ StandardizedEuclideanDistance standardizedEuclideanDistance = new StandardizedEuclideanDistance(Name);
OperationAlgorithmManager.getInstance().register(standardizedEuclideanDistance);
return standardizedEuclideanDistance;
}
}
- public EuclideanMetric toEuclideanMetric() {
- if (this.euclideanMetric != null) {
- return this.euclideanMetric;
- } else {
- String euclideanMetricName = DependentAlgorithmNameLibrary.EUCLIDEAN_METRIC_NAME;
- logger.warn("蝘唬蛹嚗[" + euclideanMetricName + "]蝞瘜鋡怠支嚗銝箔踹撘撣賂甈批敺瑞瘜璅∪甈批敺瑞瘜靘韏嚗撌脩湔亦摰記perationAlgorithmManager嚗憒冽唾踹霂亥郎嚗霂瑟典其久EuclideanMetric]蝞瘜銝舐摨嚗\n" +
- "The algorithm named: [" + euclideanMetricName + "] has been removed. To avoid exceptions, the Euclidean algorithm dependencies required by the standardized Euclidean algorithm module have been directly bound to the Operation Algorithm Manager, if you want to avoid the warning , please restart the program without deleting the [" + euclideanMetricName + "] algorithm!");
- return EuclideanMetric.getInstance(euclideanMetricName);
- }
- }
-
/**
* 憭蝏渡征港銝哨芾澈孵啣寧頝蝳鳴餈臬蝏渡征湛隞交舀銝銝芰輕摨衣寥賭鋡怨銵2甈⊥
*
@@ -82,13 +59,13 @@ public EuclideanMetric toEuclideanM
* @return Euclidean distance from its own coordinates to the origin
*/
@Override
- public double getTrueDistance(FloatingPointCoordinates iFloatingPointCoordinates) {
+ public double getTrueDistance(FloatingPointCoordinates iFloatingPointCoordinates) {
double[] doubles1 = iFloatingPointCoordinates.toArray();
double[] doublesZ = Z_ScoreNormalization.StandardizedSequence(doubles1);
if (OperationAlgorithmManager.PrintCalculationComponentLog) {
logger.info(" 踱( (iFloatingPointCoordinates(n) / StandardSequence(n))簡 )");
}
- return this.euclideanMetric.getTrueDistance(new DoubleCoordinateMany(DivideByNormalization(doubles1, doublesZ)));
+ return super.getTrueDistance(new DoubleCoordinateMany(DivideByNormalization(doubles1, doublesZ)));
}
/**
@@ -132,13 +109,13 @@ private int[] DivideByNormalization(int[] NonstandardSequence, int[] StandardSeq
* @return Euclidean distance from its own coordinates to the origin
*/
@Override
- public double getTrueDistance(IntegerCoordinates integerCoordinates) {
+ public double getTrueDistance(IntegerCoordinates integerCoordinates) {
int[] doubles1 = integerCoordinates.toArray();
int[] doublesZ = Z_ScoreNormalization.StandardizedSequence(doubles1);
if (OperationAlgorithmManager.PrintCalculationComponentLog) {
logger.info(" 踱( (integerCoordinates(n) / StandardSequence(n))簡 )");
}
- return this.euclideanMetric.getTrueDistance(new IntegerCoordinateMany(DivideByNormalization(doubles1, doublesZ)));
+ return super.getTrueDistance(new IntegerCoordinateMany(DivideByNormalization(doubles1, doublesZ)));
}
/**
@@ -152,13 +129,13 @@ public double getTrueDistance(IntegerCoordinates integerCoordinates) {
* @return True Euclidean distance between two points
*/
@Override
- public double getTrueDistance(IntegerCoordinates integerCoordinateMany1, IntegerCoordinates integerCoordinateMany2) {
+ public double getTrueDistance(IntegerCoordinates integerCoordinateMany1, IntegerCoordinates integerCoordinateMany2) {
if (OperationAlgorithmManager.PrintCalculationComponentLog) {
logger.info(" 踱( " + integerCoordinateMany1 + " - " + integerCoordinateMany2 + ").map(i -> (i / StandardSequence)簡)");
}
int[] doubles1 = integerCoordinateMany1.extend().diff(integerCoordinateMany2.extend()).toArray();
int[] doublesZ = Z_ScoreNormalization.StandardizedSequence(doubles1);
- return this.euclideanMetric.getTrueDistance(new IntegerCoordinateMany(DivideByNormalization(doubles1, doublesZ)));
+ return super.getTrueDistance(new IntegerCoordinateMany(DivideByNormalization(doubles1, doublesZ)));
}
/**
@@ -171,13 +148,13 @@ public double getTrueDistance(IntegerCoordinates integerCoordinateMany1, Inte
* @return True Euclidean distance between two points
*/
@Override
- public double getTrueDistance(FloatingPointCoordinates doubleCoordinateMany1, FloatingPointCoordinates doubleCoordinateMany2) {
+ public double getTrueDistance(FloatingPointCoordinates doubleCoordinateMany1, FloatingPointCoordinates doubleCoordinateMany2) {
if (OperationAlgorithmManager.PrintCalculationComponentLog) {
logger.info(" 踱( " + doubleCoordinateMany1 + " - " + doubleCoordinateMany2 + ").map(d -> (d / StandardSequence)簡)");
}
double[] doubles1 = doubleCoordinateMany1.diff(doubleCoordinateMany2.extend()).toArray();
double[] doublesZ = Z_ScoreNormalization.StandardizedSequence(doubles1);
- return this.euclideanMetric.getTrueDistance(new DoubleCoordinateMany(DivideByNormalization(doubles1, doublesZ)));
+ return super.getTrueDistance(new DoubleCoordinateMany(DivideByNormalization(doubles1, doublesZ)));
}
@@ -223,7 +200,7 @@ public boolean init() {
public double getTrueDistance(double[] doubles1, double[] doubles2) {
double[] doubles11 = new DoubleCoordinateMany(doubles1).diff(new DoubleCoordinateMany(doubles2)).toArray();
double[] doubles22 = Z_ScoreNormalization.StandardizedSequence(doubles11);
- return this.euclideanMetric.getTrueDistance(new DoubleCoordinateMany(DivideByNormalization(doubles11, doubles22)));
+ return super.getTrueDistance(new DoubleCoordinateMany(DivideByNormalization(doubles11, doubles22)));
}
/**
@@ -241,6 +218,46 @@ public double getTrueDistance(double[] doubles1, double[] doubles2) {
public double getTrueDistance(int[] ints1, int[] ints2) {
double[] doubles11 = new DoubleCoordinateMany(ints1).diff(new DoubleCoordinateMany(ints2)).toArray();
double[] doubles22 = Z_ScoreNormalization.StandardizedSequence(doubles11);
- return this.euclideanMetric.getTrueDistance(new DoubleCoordinateMany(DivideByNormalization(doubles11, doubles22)));
+ return super.getTrueDistance(new DoubleCoordinateMany(DivideByNormalization(doubles11, doubles22)));
+ }
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param integerMatrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(IntegerMatrix integerMatrix1, IntegerMatrix matrix2) {
+ throw new UnsupportedOperationException("The matrix does not currently support serialization operations");
+ }
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ @Override
+ public double getTrueDistance(DoubleMatrix matrix1, DoubleMatrix matrix2) {
+ throw new UnsupportedOperationException("The matrix does not currently support serialization operations");
}
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/modelAlgorithm/LinearRegression.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/modelAlgorithm/LinearRegression.java
index 93ce0d8..6d20701 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/modelAlgorithm/LinearRegression.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/modelAlgorithm/LinearRegression.java
@@ -47,10 +47,20 @@ public static LinearRegression getInstance(String Name) {
}
}
+ /**
+ * 霈曄蔭芸蝻
+ *
+ * @param featureIndex 芸蝻
+ */
public void setFeatureIndex(int featureIndex) {
this.featureIndex = featureIndex;
}
+ /**
+ * 霈曄蔭蝻
+ *
+ * @param targetIndex 蝻
+ */
public void setTargetIndex(int targetIndex) {
this.targetIndex = targetIndex;
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/DataStandardization.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/DataStandardization.java
index 382a107..611ca70 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/DataStandardization.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/DataStandardization.java
@@ -8,6 +8,8 @@
import zhao.algorithmMagic.operands.coordinate.FloatingPointCoordinates;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateMany;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinates;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
import zhao.algorithmMagic.operands.vector.DoubleVector;
import zhao.algorithmMagic.operands.vector.IntegerVector;
@@ -93,6 +95,30 @@ public String getAlgorithmName() {
*/
public abstract IntegerVector pretreatment(IntegerVector integerVector);
+ /**
+ * 撠銝銝芸餈銵嚗瑚銝摰
+ *
+ * @param doubleMatrix 閬鋡急啣潘臭誑臬嚗游靽⊥舫閬仿摰
+ *
+ * The value to be normalized, which can be a coordinate or a vector. For more information, see the implementation
+ * @return v瑕
+ *
+ * Normalized style of v
+ */
+ public abstract DoubleMatrix pretreatment(DoubleMatrix doubleMatrix);
+
+ /**
+ * 撠銝銝芸餈銵嚗瑚銝摰
+ *
+ * @param integerMatrix 閬鋡急啣潘臭誑臬嚗游靽⊥舫閬仿摰
+ *
+ * The value to be normalized, which can be a coordinate or a vector. For more information, see the implementation
+ * @return v瑕
+ *
+ * Normalized style of v
+ */
+ public abstract IntegerMatrix pretreatment(IntegerMatrix integerMatrix);
+
/**
* 蝞瘜璅∪憪寞嚗刻典臭誑餈銵蝏隞嗥憪寞嚗敶憪銋嚗霂亦瘜撠勗臭誑憭鈭撠梁貌嗆嚗銝祈撠望臬芸楛瘛餃啁瘜蝞∠蝐颱葉
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/LinearNormalization.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/LinearNormalization.java
index 2b30f7a..53dbf72 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/LinearNormalization.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/LinearNormalization.java
@@ -7,6 +7,8 @@
import zhao.algorithmMagic.operands.coordinate.FloatingPointCoordinates;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateMany;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinates;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
import zhao.algorithmMagic.operands.vector.DoubleVector;
import zhao.algorithmMagic.operands.vector.FastRangeDoubleVector;
import zhao.algorithmMagic.operands.vector.FastRangeIntegerVector;
@@ -69,13 +71,13 @@ public static LinearNormalization getInstance(String Name) {
* @param doubles 閬鋡急銝銝芸
* @return 蝏
*/
- public static double[] normalization(double[] doubles, double min1, double max1) {
+ public static double[] pretreatment(double[] doubles, double min1, double max1) {
// 霈∠憭批潭撠
double[] doubles1 = ASMath.MaxAndMin(doubles);
double max = doubles1[0b0];
double min = doubles1[0b1];
// 撘憪撠摨
- return normalization(doubles, min, max, min1, max1);
+ return pretreatment(doubles, min, max, min1, max1);
}
/**
@@ -88,7 +90,7 @@ public static double[] normalization(double[] doubles, double min1, double max1)
* @param min1 敶銝銋瘥銝銝芸蝝霈貊憭批
* @return 敶銝銋啣啁撖寡情
*/
- public static double[] normalization(double[] doubles, double min, double max, double min1, double max1) {
+ public static double[] pretreatment(double[] doubles, double min, double max, double min1, double max1) {
double[] res = new double[doubles.length];
// 斗剜臬阡閬敶銝嚗銝閬撠勗瑁
if (max <= max1 && min >= min1) {
@@ -114,12 +116,12 @@ public static double[] normalization(double[] doubles, double min, double max, d
* @param ints 閬鋡急銝銝芸
* @return 蝏
*/
- public static int[] normalization(int[] ints, int min1, int max1) {
+ public static int[] pretreatment(int[] ints, int min1, int max1) {
int[] doubles1 = ASMath.MaxAndMin(ints);
int max = doubles1[0b0];
int min = doubles1[0b1];
// 撘憪撠摨
- return normalization(ints, min, max, min1, max1);
+ return pretreatment(ints, min, max, min1, max1);
}
/**
@@ -132,7 +134,7 @@ public static int[] normalization(int[] ints, int min1, int max1) {
* @param min1 敶銝銋瘥銝銝芸蝝霈貊憭批
* @return 敶銝銋啣撖寡情啁
*/
- public static int[] normalization(int[] ints, int min, int max, int min1, int max1) {
+ public static int[] pretreatment(int[] ints, int min, int max, int min1, int max1) {
int[] res = new int[ints.length];
// 斗剜臬阡閬敶銝嚗銝閬撠勗瑁
if (max <= max1 && min >= min1) {
@@ -148,6 +150,100 @@ public static int[] normalization(int[] ints, int min, int max, int min1, int ma
return res;
}
+ /**
+ * 撠銝銝芸蝏游嚗畾萄停臬v銝剔瘥銝銝芣啣潸銵餈蝞嚗Xn = 嚗Xn - min(x)嚗/ max(x) - min(x)
+ *
+ * To normalize a multidimensional sequence, the normalization method is to operate on each value in the sequence v: x = (x - min(x)) max(x) - min(x)
+ *
+ * @param max1 敶銝銋瘥銝銝芸蝝霈貊撠
+ * @param min1 敶銝銋瘥銝銝芸蝝霈貊憭批
+ * @param ints 閬鋡急銝銝芸
+ * @return 蝏
+ */
+ public static int[][] pretreatment(int[][] ints, int min1, int max1) {
+ int[] doubles1 = ASMath.MaxAndMin(ints);
+ int max = doubles1[0b0];
+ int min = doubles1[0b1];
+ // 撘憪撠摨
+ return pretreatment(ints, min, max, min1, max1);
+ }
+
+ /**
+ * 撠銝銝芸蝏游敶銝嚗刻砲賣唬葉臭誑摰敶銝銋蝏粹湔啣
+ *
+ * @param ints 閬鋡怠銝摨
+ * @param min 摨銝剔憭批
+ * @param max 摨銝剔撠
+ * @param max1 敶銝銋瘥銝銝芸蝝霈貊撠
+ * @param min1 敶銝銋瘥銝銝芸蝝霈貊憭批
+ * @return 敶銝銋啣撖寡情啁
+ */
+ public static int[][] pretreatment(int[][] ints, int min, int max, int min1, int max1) {
+ int[][] res1 = new int[ints.length][ints[0].length];
+ // 斗剜臬阡閬敶銝嚗銝閬撠勗瑁
+ if (max <= max1 && min >= min1) {
+ return ASClass.array2DCopy(ints, res1);
+ }
+ // 憒閬撠勗憪敶銝
+ int MAX_MIN = max - min;
+ int MAX_MIN1 = max1 - min1;
+ int y = -1;
+ for (int[] res : ints) {
+ int[] ints1 = res1[++y];
+ for (int i = 0; i < res.length; i++) {
+ ints1[i] = (int) (((res[i] - min) / (double) MAX_MIN) * MAX_MIN1 + min1);
+ }
+ }
+ return res1;
+ }
+
+
+ /**
+ * 撠銝銝芸蝏游嚗畾萄停臬v銝剔瘥銝銝芣啣潸銵餈蝞嚗Xn = 嚗Xn - min(x)嚗/ max(x) - min(x)
+ *
+ * To normalize a multidimensional sequence, the normalization method is to operate on each value in the sequence v: x = (x - min(x)) max(x) - min(x)
+ *
+ * @param max1 敶銝銋瘥銝銝芸蝝霈貊撠
+ * @param min1 敶銝銋瘥銝銝芸蝝霈貊憭批
+ * @param doubles 閬鋡急銝銝芸
+ * @return 蝏
+ */
+ public static double[][] pretreatment(double[][] doubles, double min1, double max1) {
+ // 霈∠憭批潭撠
+ double[] doubles1 = ASMath.MaxAndMin(doubles);
+ // 撘憪撠摨
+ return pretreatment(doubles, doubles1[0b1], doubles1[0b0], min1, max1);
+ }
+
+ /**
+ * 撠銝銝芸蝏游敶銝嚗刻砲賣唬葉臭誑摰敶銝銋蝏粹湔啣
+ *
+ * @param ints 閬鋡怠銝摨
+ * @param min 摨銝剔憭批
+ * @param max 摨銝剔撠
+ * @param max1 敶銝銋瘥銝銝芸蝝霈貊撠
+ * @param min1 敶銝銋瘥銝銝芸蝝霈貊憭批
+ * @return 敶銝銋啣撖寡情啁
+ */
+ public static double[][] pretreatment(double[][] ints, double min, double max, double min1, double max1) {
+ double[][] res1 = new double[ints.length][ints[0].length];
+ // 斗剜臬阡閬敶銝嚗銝閬撠勗瑁
+ if (max <= max1 && min >= min1) {
+ return ASClass.array2DCopy(ints, res1);
+ }
+ // 憒閬撠勗憪敶銝
+ double MAX_MIN = max - min;
+ double MAX_MIN1 = max1 - min1;
+ int y = -1;
+ for (double[] res : ints) {
+ double[] doubles = res1[++y];
+ for (int i = 0; i < res.length; i++) {
+ doubles[i] = ((res[i] - min) / MAX_MIN) * MAX_MIN1 + min1;
+ }
+ }
+ return res1;
+ }
+
/**
* 霈曄蔭敶銝銋摨憭批
*
@@ -182,7 +278,7 @@ public LinearNormalization setMin(double min) {
*/
@Override
public FloatingPointCoordinates pretreatment(DoubleCoordinateMany v) {
- return new DoubleCoordinateMany(normalization(v.toArray(), min, max));
+ return new DoubleCoordinateMany(pretreatment(v.toArray(), min, max));
}
/**
@@ -197,7 +293,7 @@ public FloatingPointCoordinates pretreatment(DoubleCoordin
*/
@Override
public IntegerCoordinates pretreatment(IntegerCoordinateMany v) {
- return new IntegerCoordinateMany(normalization(v.toArray(), (int) min, (int) max));
+ return new IntegerCoordinateMany(pretreatment(v.toArray(), (int) min, (int) max));
}
/**
@@ -210,7 +306,7 @@ public IntegerCoordinates pretreatment(IntegerCoordinateM
*/
@Override
public DoubleVector pretreatment(DoubleVector doubleVector) {
- return new DoubleVector(normalization(doubleVector.toArray(), min, max));
+ return new DoubleVector(pretreatment(doubleVector.toArray(), min, max));
}
/**
@@ -223,7 +319,37 @@ public DoubleVector pretreatment(DoubleVector doubleVector) {
*/
@Override
public IntegerVector pretreatment(IntegerVector integerVector) {
- return new IntegerVector(normalization(integerVector.toArray(), (int) min, (int) max));
+ return new IntegerVector(pretreatment(integerVector.toArray(), (int) min, (int) max));
+ }
+
+ /**
+ * 撠銝銝芸餈銵嚗瑚銝摰
+ *
+ * @param doubleMatrix 閬鋡急啣潘臭誑臬嚗游靽⊥舫閬仿摰
+ *
+ * The value to be normalized, which can be a coordinate or a vector. For more information, see the implementation
+ * @return v瑕
+ *
+ * Normalized style of v
+ */
+ @Override
+ public DoubleMatrix pretreatment(DoubleMatrix doubleMatrix) {
+ return DoubleMatrix.parse(pretreatment(doubleMatrix.toArrays(), min, max));
+ }
+
+ /**
+ * 撠銝銝芸餈銵嚗瑚銝摰
+ *
+ * @param integerMatrix 閬鋡急啣潘臭誑臬嚗游靽⊥舫閬仿摰
+ *
+ * The value to be normalized, which can be a coordinate or a vector. For more information, see the implementation
+ * @return v瑕
+ *
+ * Normalized style of v
+ */
+ @Override
+ public IntegerMatrix pretreatment(IntegerMatrix integerMatrix) {
+ return IntegerMatrix.parse(pretreatment(integerMatrix.toArrays(), (int) min, (int) max));
}
/**
diff --git a/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/Z_ScoreNormalization.java b/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/Z_ScoreNormalization.java
index 9675972..1a8f4d3 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/Z_ScoreNormalization.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/algorithm/normalization/Z_ScoreNormalization.java
@@ -8,6 +8,8 @@
import zhao.algorithmMagic.operands.coordinate.FloatingPointCoordinates;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateMany;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinates;
+import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
import zhao.algorithmMagic.operands.vector.DoubleVector;
import zhao.algorithmMagic.operands.vector.FastRangeDoubleVector;
import zhao.algorithmMagic.operands.vector.FastRangeIntegerVector;
@@ -171,6 +173,36 @@ public IntegerVector pretreatment(IntegerVector integerVector) {
return new IntegerVector(StandardizedSequence(integerVector.toArray()));
}
+ /**
+ * 撠銝銝芸餈銵嚗瑚銝摰
+ *
+ * @param doubleMatrix 閬鋡急啣潘臭誑臬嚗游靽⊥舫閬仿摰
+ *
+ * The value to be normalized, which can be a coordinate or a vector. For more information, see the implementation
+ * @return v瑕
+ *
+ * Normalized style of v
+ */
+ @Override
+ public DoubleMatrix pretreatment(DoubleMatrix doubleMatrix) {
+ throw new UnsupportedOperationException("The matrix currently does not support standardization operations.");
+ }
+
+ /**
+ * 撠銝銝芸餈銵嚗瑚銝摰
+ *
+ * @param integerMatrix 閬鋡急啣潘臭誑臬嚗游靽⊥舫閬仿摰
+ *
+ * The value to be normalized, which can be a coordinate or a vector. For more information, see the implementation
+ * @return v瑕
+ *
+ * Normalized style of v
+ */
+ @Override
+ public IntegerMatrix pretreatment(IntegerMatrix integerMatrix) {
+ throw new UnsupportedOperationException("The matrix currently does not support standardization operations.");
+ }
+
/**
* 撠銝銝芸餈銵嚗瑚銝摰
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/core/AlgorithmStar.java b/src_code/src/main/java/zhao/algorithmMagic/core/AlgorithmStar.java
index c047db6..583cd19 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/core/AlgorithmStar.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/core/AlgorithmStar.java
@@ -13,22 +13,26 @@
import zhao.algorithmMagic.algorithm.normalization.RangeDataStandardization;
import zhao.algorithmMagic.algorithm.probabilisticAlgorithm.ProbabilisticAlgorithm;
import zhao.algorithmMagic.algorithm.schemeAlgorithm.SchemeAlgorithm;
+import zhao.algorithmMagic.io.InputComponent;
import zhao.algorithmMagic.operands.coordinate.DoubleCoordinateMany;
import zhao.algorithmMagic.operands.coordinate.FloatingPointCoordinates;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateMany;
import zhao.algorithmMagic.operands.coordinate.IntegerCoordinates;
-import zhao.algorithmMagic.operands.matrix.ColumnDoubleMatrix;
-import zhao.algorithmMagic.operands.matrix.ColumnIntegerMatrix;
-import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
-import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
+import zhao.algorithmMagic.operands.matrix.*;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute;
import zhao.algorithmMagic.operands.route.DoubleConsanguinityRoute2D;
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute;
import zhao.algorithmMagic.operands.route.IntegerConsanguinityRoute2D;
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.DataFrameBuilder;
+import zhao.algorithmMagic.operands.table.FDataFrame;
import zhao.algorithmMagic.operands.vector.*;
import zhao.algorithmMagic.utils.filter.ArrayDoubleFiltering;
import zhao.algorithmMagic.utils.filter.ArrayIntegerFiltering;
+import java.io.File;
+import java.net.URL;
+import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -90,6 +94,132 @@ public static void clear() {
********************************************************************
*/
+ /**
+ * 銝銝芰拚蛛拚萇圈隞亦拚萇蝚砌銵銝箏嚗
+ *
+ * Construct a matrix, the number of columns of the matrix is based on the first row of the matrix!
+ *
+ * @param v 其拚萇鈭蝏湔啁
+ *
+ * 2D array for constructing the matrix
+ * @return matrix object
+ */
+ public static IntegerMatrix parseIntMat(int[]... v) {
+ return IntegerMatrix.parse(v);
+ }
+
+ /**
+ * 銝銝芰拚蛛拚萇圈隞亦拚萇蝚砌銵銝箏嚗
+ *
+ * Construct a matrix, the number of columns of the matrix is based on the first row of the matrix!
+ *
+ * @param v 其拚萇鈭蝏湔啁
+ *
+ * 2D array for constructing the matrix
+ * @return matrix object
+ */
+ public static DoubleMatrix parseDoubleMat(double[]... v) {
+ return DoubleMatrix.parse(v);
+ }
+
+ /**
+ * 隞砍唳隞嗥頂蝏銝剛粉銝銝芣唳桀笆鞊∴撟嗉撖孵唳桀笆鞊∠撱粹蝐颯
+ *
+ * @param file 閬鋡怨粉隞嗅笆鞊∼
+ * @return 霂餃銋隡餈霂交唳桅撖孵銝銝芸遣撖寡情嚗刻砲撖寡情銝剖臭誑撖寡粉雿餈銵游霂衣霈曄蔭嚗
+ */
+ public static DataFrameBuilder parseDF(File file) {
+ return FDataFrame.builder(file);
+ }
+
+ /**
+ * 隞餈蝔唳桀銝剛粉銝銝芣唳桀笆鞊∴撟嗉唳桀笆鞊∪笆摨撱粹蝐颯
+ *
+ * @param DBC 刻交唳桀園閬雿輻函唳桀餈亙笆鞊∼
+ * @return 唳桀餈亥挽蝵桀瘥撠隡餈銝銝芸遣撖寡情嚗刻砲撖寡情銝剖臭誑撖寡粉唳桀雿餈銵游霂衣霈曄蔭
+ */
+ public static DataFrameBuilder parseDF(Connection DBC) {
+ return FDataFrame.builder(DBC);
+ }
+
+ /**
+ * 雿輻函洵銝寞唳格颲亦隞嗉銵唳桃頧踝撟嗉瑕啣笆摨DataFrame撖寡情
+ *
+ * @param inputComponent 閬雿輻函蝚砌寞唳株亦隞嗅笆鞊
+ * @param isOC 憒霈曄蔭銝 true 隞銵冽唳株亥挽憭撖寡情撘銝喲凋漱望嗥恣嚗典撠銝閬撖寧隞嗉銵撘喲剜雿嚗銋隞銵冽嗅芯蝙函隞塚雿銝隡撘銝喲剔隞嗅笆鞊∼
+ *
+ * If set to true, it means that the opening and closing of data input device objects are managed by the framework, and there will be no need to open or close components externally. Conversely, it means that the framework only uses components, but will not open or close component objects.
+ * @return 瑕啁DataFrame撖寡情
+ */
+ public static DataFrame parseDF(InputComponent inputComponent, boolean isOC) {
+ return FDataFrame.builder(inputComponent, isOC);
+ }
+
+ /**
+ * 雿輻函隞嗅銝銝芸曉唳格嚗撟嗉瑕撖孵曉拚萸
+ *
+ * @param inputComponent 賢鋡急箏曉拚萇唳桃隞嗚
+ * @param isOC 憒霈曄蔭銝 true 隞銵冽唳株亥挽憭撖寡情撘銝喲凋漱望嗥恣嚗典撠銝閬撖寧隞嗉銵撘喲剜雿嚗銋隞銵冽嗅芯蝙函隞塚雿銝隡撘銝喲剔隞嗅笆鞊∼
+ *
+ * If set to true, it means that the opening and closing of data input device objects are managed by the framework, and there will be no need to open or close components externally. Conversely, it means that the framework only uses components, but will not open or close component objects.
+ * @return 隞蝏隞嗡葉箸亦曉拚萄笆鞊∼
+ */
+ public static ColorMatrix parseImage(InputComponent inputComponent, boolean isOC) {
+ return ColorMatrix.parse(inputComponent, isOC);
+ }
+
+ /**
+ * 撠曉URL閫嚗撟嗉瑕撖孵曉拚
+ *
+ * @param url 閬鋡怨圾URL撖寡情
+ * @return URL撖寡情撖孵曉拚萸
+ */
+ public static ColorMatrix parseImage(URL url) {
+ return ColorMatrix.parse(url);
+ }
+
+ /**
+ * 撠曉URL閫嚗撟嗉瑕撖孵曉拚
+ *
+ * @param url 閬鋡怨圾URL撖寡情
+ * @return URL撖寡情撖孵曉拚萸
+ */
+ public static ColorMatrix parseGrayscaleImage(URL url) {
+ return ColorMatrix.parseGrayscale(url);
+ }
+
+ /**
+ * 寞桀曉隞嗉瑕唳游耦拚萄笆鞊∴冽游耦拚萄笆鞊∩葉隡怨砲曉瘥銝銝芸蝝孵笆摨啣漲游耦啣潦
+ *
+ * The reshaping matrix object is obtained from the image file, and the reshaping value corresponding to each pixel of the image will be included in the reshaping matrix object.
+ *
+ * @param imagePath 閬霂餃格曉隞嗉楝敺
+ *
+ * The target image file path to read.
+ * @return 寞桀曉瑕啁拚萄笆鞊∼
+ *
+ * The matrix object obtained from the image.
+ */
+ public static ColorMatrix parseImage(String imagePath) {
+ return ColorMatrix.parse(imagePath);
+ }
+
+ /**
+ * 寞桀曉隞嗉瑕唳游耦拚萄笆鞊∴冽游耦拚萄笆鞊∩葉隡怨砲曉瘥銝銝芸蝝孵笆摨啣漲游耦啣潦
+ *
+ * The reshaping matrix object is obtained from the image file, and the reshaping value corresponding to each pixel of the image will be included in the reshaping matrix object.
+ *
+ * @param imagePath 閬霂餃格曉隞嗉楝敺
+ *
+ * The target image file path to read.
+ * @return 寞桀曉瑕啁拚萄笆鞊∼
+ *
+ * The matrix object obtained from the image.
+ */
+ public static ColorMatrix parseGrayscaleImage(String imagePath) {
+ return ColorMatrix.parseGrayscale(imagePath);
+ }
+
/**
* 霈∠銝銝芾楝蝥輻韏瑕嫣蝏甇Y寧摰頝蝳颯瑚頝蝳餃堆閬冽仿蝞瘜摰啁獢
*
@@ -139,6 +269,13 @@ public double getTrueDistance(DistanceAlgorithm distanceAlgorithm, int[] ints1,
return distanceAlgorithm.getTrueDistance(ints1, ints2);
}
+ /*
+ ********************************************************************
+ * 蝞瘜蝏隞嗉恣蝞賣啣憪蝥
+ * Aggregation algorithm component calculation function start boundary
+ ********************************************************************
+ */
+
/**
* 霈∠銝銝芾楝蝥輻韏瑕嫣蝏甇Y寧摰頝蝳颯瑚頝蝳餃堆閬冽仿蝞瘜摰啁獢
*
@@ -190,6 +327,58 @@ public double getTrueDistance(DistanceAlgorithm distanceAlgorithm, IntegerConsan
return distanceAlgorithm.getTrueDistance(integerConsanguinityRoute2D);
}
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param distanceAlgorithm 頝蝳餉恣蝞蝏隞塚舀典刻冽祆活賣唬嚗賣啁冽亥恣蝞頝蝳餉恣蝞蝏隞嗅笆鞊∼
+ *
+ * The distance calculation component is the distance calculation component object that the function uses to calculate after you call this function.
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ public double getTrueDistance(DistanceAlgorithm distanceAlgorithm, IntegerMatrix matrix1, IntegerMatrix matrix2) {
+ return distanceAlgorithm.getTrueDistance(matrix1, matrix2);
+ }
+
+ /**
+ * 霈∠銝支葵拚萄笆鞊∩渡頝蝳餃漲賣堆餈霂亙賣啣臭誑摰唬舅銝芰拚萄笆鞊∪漲蝟餅啁霈∠
+ *
+ * Calculates the distance metric function between two matrix objects, through which the metric coefficients of two matrix objects can be calculated.
+ *
+ * @param distanceAlgorithm 頝蝳餉恣蝞蝏隞塚舀典刻冽祆活賣唬嚗賣啁冽亥恣蝞頝蝳餉恣蝞蝏隞嗅笆鞊∼
+ *
+ * The distance calculation component is the distance calculation component object that the function uses to calculate after you call this function.
+ * @param matrix1 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @param matrix2 閬鋡怨銵霈∠拚萄笆鞊∼
+ *
+ * The matrix object that needs to be calculated.
+ * @return 霈∠箸亦摨阡蝏蝟餅啜
+ *
+ * The calculated measurement result coefficient.
+ */
+ public double getTrueDistance(DistanceAlgorithm distanceAlgorithm, DoubleMatrix matrix1, DoubleMatrix matrix2) {
+ return distanceAlgorithm.getTrueDistance(matrix1, matrix2);
+ }
+
+
+ /*
+ ********************************************************************
+ * 蝐餌瘜蝏隞嗉恣蝞賣啣憪蝥
+ * Classification algorithm component calculation function start boundary
+ ********************************************************************
+ */
+
/**
* 霈∠頝蝳餃寧頝蝳颯
*
@@ -203,13 +392,6 @@ public double getTrueDistance(RangeDistance rangeDistance, RangeVector, ?, ?,
return rangeDistance.getTrueDistance(rangeVector);
}
- /*
- ********************************************************************
- * 蝞瘜蝏隞嗉恣蝞賣啣憪蝥
- * Aggregation algorithm component calculation function start boundary
- ********************************************************************
- */
-
/**
* 霈∠賣堆撠銝芣啁銝剔蝝扳銝芾餈銵
*
@@ -227,7 +409,6 @@ public double calculation(AggregationAlgorithm aggregationAlgorithm, double... d
return aggregationAlgorithm.calculation(doubles);
}
-
/**
* 霈∠賣堆撠銝芣啁銝剔蝝扳銝芾餈銵
*
@@ -306,14 +487,6 @@ public double calculation(RangeAggregation rangeAggregation, RangeVector, ?, ?
return rangeAggregation.calculation(rangeVector);
}
-
- /*
- ********************************************************************
- * 蝐餌瘜蝏隞嗉恣蝞賣啣憪蝥
- * Classification algorithm component calculation function start boundary
- ********************************************************************
- */
-
/**
* 瑟祉頝蝳餉恣蝞嚗典冽迨餈銵蝐鳴銝閬隡敺憭唳格瑟穿芷閬勗啁掩扯芸楛蝞瘜餈銵蝐餃急冽剖喳胯
*
@@ -400,6 +573,13 @@ public HashMap> classification(NoSampleClassific
return noSampleClassification.classification(keys, doubles);
}
+ /*
+ ********************************************************************
+ * 撌桀蝞瘜蝏隞嗉恣蝞賣啣憪蝥 *
+ * diff algorithm component calculation function start boundary *
+ ********************************************************************
+ */
+
/**
* 瑟祉頝蝳餉恣蝞嚗典冽迨餈銵蝐鳴銝閬隡敺憭唳格瑟穿芷閬勗啁掩扯芸楛蝞瘜餈銵蝐餃急冽剖喳胯
*
@@ -422,6 +602,13 @@ public HashMap> classification(NoSampleCl
return noSampleClassification.classification(keys, columnIntegerMatrix);
}
+ /*
+ ********************************************************************
+ * 孵蝞瘜蝏隞嗉恣蝞賣啣憪蝥 *
+ * FeatureExtraction algorithm component calculation function start boundary *
+ ********************************************************************
+ */
+
/**
* 瑟祉頝蝳餉恣蝞嚗典冽迨餈銵蝐鳴銝閬隡敺憭唳格瑟穿芷閬勗啁掩扯芸楛蝞瘜餈銵蝐餃急冽剖喳胯
*
@@ -444,6 +631,12 @@ public HashMap> classification(NoSampleCla
return noSampleClassification.classification(keys, columnDoubleMatrix);
}
+ /*
+ ********************************************************************
+ * 唳桅憭蝞瘜蝏隞嗉恣蝞賣啣憪蝥 *
+ * Data preprocessing algorithm component calculation function start boundary *
+ ********************************************************************
+ */
/**
* 霈∠銝銝芰拚萎葉銵唳桃掩恬撟嗅霈∠銋唳桃掩急瑟祈箏颯
@@ -549,14 +742,6 @@ public HashMap> classification(SampleClassifica
return sampleClassification.classification(data, categorySample);
}
- /*
- ********************************************************************
- * 撌桀蝞瘜蝏隞嗉恣蝞賣啣憪蝥 *
- * diff algorithm component calculation function start boundary *
- ********************************************************************
- */
-
-
/**
* 霈∠銝支葵鈭拐港撌桀蝟餅啁曉瘥
*
@@ -571,13 +756,6 @@ public double getDifferenceRatio(DifferenceAlgorithm differenceAlgori
return differenceAlgorithm.getDifferenceRatio(value1, value2);
}
- /*
- ********************************************************************
- * 孵蝞瘜蝏隞嗉恣蝞賣啣憪蝥 *
- * FeatureExtraction algorithm component calculation function start boundary *
- ********************************************************************
- */
-
/**
* 撠敺憭摮蝚虫葡蝏韏瑟亥銵孵嚗嗡葉瘥銝銝芾賣臭銝芰孵潦
*
@@ -591,13 +769,6 @@ public featureReturn extract(StringArrayFeature stringArrayFeatur
return stringArrayFeature.extract(data);
}
- /*
- ********************************************************************
- * 唳桅憭蝞瘜蝏隞嗉恣蝞賣啣憪蝥 *
- * Data preprocessing algorithm component calculation function start boundary *
- ********************************************************************
- */
-
/**
* 撠銝銝芸餈銵嚗瑚銝摰
*
@@ -628,6 +799,43 @@ public IntegerCoordinates pretreatment(DataStandardizatio
return dataStandardization.pretreatment(v);
}
+ /*
+ ********************************************************************
+ * 璁蝞瘜蝏隞嗉恣蝞賣啣憪蝥
+ * Probability algorithm component calculation function start boundary
+ ********************************************************************
+ */
+
+ /**
+ * 撠銝銝芸餈銵嚗瑚銝摰
+ *
+ * @param dataStandardization 閬雿輻函唳桅憭蝞瘜蝏隞嗅笆鞊∼
+ * @param integerMatrix 閬鋡急啣潘臭誑臬嚗游靽⊥舫閬仿摰
+ *
+ * The value to be normalized, which can be a coordinate or a vector. For more information, see the implementation
+ * @return v瑕
+ *
+ * Normalized style of v
+ */
+ public IntegerMatrix pretreatment(DataStandardization dataStandardization, IntegerMatrix integerMatrix) {
+ return dataStandardization.pretreatment(integerMatrix);
+ }
+
+ /**
+ * 撠銝銝芸餈銵嚗瑚銝摰
+ *
+ * @param dataStandardization 閬雿輻函唳桅憭蝞瘜蝏隞嗅笆鞊∼
+ * @param doubleMatrix 閬鋡急啣潘臭誑臬嚗游靽⊥舫閬仿摰
+ *
+ * The value to be normalized, which can be a coordinate or a vector. For more information, see the implementation
+ * @return v瑕
+ *
+ * Normalized style of v
+ */
+ public DoubleMatrix pretreatment(DataStandardization dataStandardization, DoubleMatrix doubleMatrix) {
+ return dataStandardization.pretreatment(doubleMatrix);
+ }
+
/**
* 撠銝銝芸餈銵嚗瑚銝摰
*
@@ -692,13 +900,6 @@ public DoubleVector pretreatment(RangeDataStandardization rangeDataStandardizati
return rangeDataStandardization.pretreatment(fastRangeDoubleVector);
}
- /*
- ********************************************************************
- * 璁蝞瘜蝏隞嗉恣蝞賣啣憪蝥
- * Probability algorithm component calculation function start boundary
- ********************************************************************
- */
-
/**
* 霈∠銝銝芰拚萎葉鈭∩辣嗡璁蝏 P(A|B) 嗡葉摮銝瘥潘
*
@@ -833,7 +1034,6 @@ public ArrayList decision(SchemeAlgorithm schemeAlgorithm,
return decision(schemeAlgorithm, doubleMatrix.toArrays(), 2, arrayDoubleFiltering);
}
-
/**
* 餈喟嚗撖嫣餈餈亦喟摨唳嚗雿踹嗆銝箸隡閫
*
@@ -878,7 +1078,6 @@ public ArrayList decision(SchemeAlgorithm schemeAlgorithm,
return decision(schemeAlgorithm, ints, 2, arrayDoubleFiltering);
}
-
/**
* 餈喟嚗撖嫣餈餈亦喟摨唳嚗雿踹嗆銝箸隡閫
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/integrator/ImageRenderingIntegrator.java b/src_code/src/main/java/zhao/algorithmMagic/integrator/ImageRenderingIntegrator.java
index 8559a2f..9f406f8 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/integrator/ImageRenderingIntegrator.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/integrator/ImageRenderingIntegrator.java
@@ -93,6 +93,20 @@ public static boolean draw(String outFilePath, int[][] ints, int imageWidth, int
* @return 憒餈true 隞銵函嗆嚗
*/
public static boolean draw(String outFilePath, Color[][] colors, int imageWidth, int imageHeight, int pixelMagnification, boolean writeNumber) {
+ BufferedImage image = drawBufferedImage(colors, imageWidth, imageHeight, pixelMagnification, writeNumber);
+ // 颲箏曄
+ return ASIO.outImage(image, outFilePath);
+ }
+
+ /**
+ * @param colors 閬鋡怎冽乩銝箏曉颲箇蝝拚萄笆鞊
+ * @param imageWidth 閬蝏嗅曉摰賢漲
+ * @param imageHeight 閬蝏嗅曉擃摨
+ * @param pixelMagnification 拚萎葉銝銝芸蝝隞銵函蝝嚗銋臭銝芸蝝憭批
+ * @param writeNumber 憒霈曄蔭銝演rue嚗隞銵刻箏曄嗅撠憸脩瑟銝
+ * @return 憒餈true 隞銵函嗆嚗
+ */
+ public static BufferedImage drawBufferedImage(Color[][] colors, int imageWidth, int imageHeight, int pixelMagnification, boolean writeNumber) {
// 撱箔銝芸曄
int width = imageWidth * pixelMagnification;
int height = imageHeight * pixelMagnification;
@@ -125,8 +139,7 @@ public static boolean draw(String outFilePath, Color[][] colors, int imageWidth,
x1 = 0;
}
}
- // 颲箏曄
- return ASIO.outImage(image, outFilePath);
+ return image;
}
@Override
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/InputBuilder.java b/src_code/src/main/java/zhao/algorithmMagic/io/InputBuilder.java
new file mode 100644
index 0000000..9ce8784
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/InputBuilder.java
@@ -0,0 +1,39 @@
+package zhao.algorithmMagic.io;
+
+import zhao.algorithmMagic.operands.table.FinalCell;
+
+/**
+ * 唳株亦隞嗥剁嗆祈澈雿銝箸唳株亥挽憭撖寡情撱粹撖寡情
+ *
+ * The data input component generator itself serves as the creator object for all data input device objects.
+ *
+ * @author 韏萄摰
+ * 2023/4/5 13:54
+ */
+public interface InputBuilder {
+
+ /**
+ * 瘛餃唳株交餈堆銝蝏隞嗆銝蝵桀改瑚臭誑摰啁掩
+ *
+ * Add data input descriptions, and different components have different configuration properties. Please refer to the implementation class for details.
+ *
+ * @param key 撅批蝘
+ *
+ * Attribute Name.
+ * @param value 撅扳啣
+ *
+ * Attribute Value.
+ * @return 曉靚剁蝏抒賒撱
+ *
+ * Chain call, continue building.
+ */
+ InputBuilder addInputArg(String key, FinalCell> value);
+
+ /**
+ * 撠撖寡情撱箏箸亙僎瑕啣笆摨颲亥挽憭撖寡情
+ *
+ * @return 颲亥挽憭撖寡情
+ */
+ InputComponent create();
+
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/InputByStream.java b/src_code/src/main/java/zhao/algorithmMagic/io/InputByStream.java
new file mode 100644
index 0000000..d36c9ec
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/InputByStream.java
@@ -0,0 +1,220 @@
+package zhao.algorithmMagic.io;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import zhao.algorithmMagic.exception.OperatorOperationException;
+import zhao.algorithmMagic.operands.table.*;
+import zhao.algorithmMagic.utils.ASIO;
+import zhao.algorithmMagic.utils.ASStr;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.Scanner;
+
+/**
+ * 隞銝銝芣唳株交銝剛瑕唳桃摰啁掩嚗霂亦掩銝剖鋆鈭銝蝟餃餈唳株交瑕唳唳桃雿
+ *
+ * An implementation class that obtains data from a data input stream, encapsulating a series of operations to obtain data through the data input stream.
+ *
+ * @author zhao
+ */
+public class InputByStream implements InputComponent {
+
+ private final static Logger LOGGER = LoggerFactory.getLogger("InputByStream");
+ private final InputStream inputStream;
+ private final Scanner scanner;
+ private final Charset charSet;
+ private final int rowLength;
+ private final int pk;
+ private final char sep;
+
+ /**
+ * @param inputStream 閬鋡怨粉唳株交撖寡情
+ * @param charSet 唳株亙蝚佗蝏唳桅閬雿輻冽迨
+ * @param rowLength 唳株亥堆蝏唳桅閬雿輻冽迨
+ * @param pk 唳桐蜓殷DF唳株仿閬雿輻冽迨
+ * @param sep 唳株亙蝚佗蝏唳株仿閬甇文
+ */
+ public InputByStream(Cell inputStream, Cell charSet, int rowLength, int pk, char sep) {
+ if (inputStream == null || charSet == null) {
+ throw new OperatorOperationException("The parameter in [Cell inputStream, Cell charSet] cannot be null!!!!");
+ }
+ this.inputStream = inputStream.getValue();
+ scanner = new Scanner(this.inputStream);
+ this.charSet = Charset.forName(charSet.toString());
+ this.rowLength = rowLength;
+ this.pk = pk;
+ this.sep = sep;
+ }
+
+ public static InputBuilder builder() {
+ return new InputByStreamBuilder();
+ }
+
+ /**
+ * 臬冽唳株亦隞
+ *
+ * @return 憒臬冽餈true
+ */
+ @Override
+ public boolean open() {
+ LOGGER.info("open()");
+ LOGGER.info("The data input stream component is ready!!!!");
+ return isOpen();
+ }
+
+ /**
+ * @return 憒蝏隞嗅歇蝏臬其嚗刻餈true
+ *
+ * If the component has already started, return true here.
+ */
+ @Override
+ public boolean isOpen() {
+ LOGGER.info("isOpen()");
+ return true;
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 byte 啁唳殷銝祆萎嚗餈餈賣臭鈭鈭餈嗥唳柴
+ *
+ * Extract the data of the byte array from the data input component. Generally, the returned data here is some binary data.
+ *
+ * @return byte[] 唳桀笆鞊
+ */
+ @Override
+ public byte[] getByteArray() {
+ LOGGER.info("getByteArray()");
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ try {
+ while (scanner.hasNext()) {
+ byteArrayOutputStream.write(scanner.nextLine().getBytes(charSet));
+ }
+ return byteArrayOutputStream.toByteArray();
+ } catch (IOException e) {
+ throw new OperatorOperationException(e);
+ } finally {
+ ASIO.close(byteArrayOutputStream);
+ }
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 int 拚菜唳殷銝祆萎嚗餈餈臭鈭拚萄蝝唳柴
+ *
+ * From the data input component, int matrix data is increasingly generated. Generally, some matrix element data is returned here.
+ *
+ * @return int[][]
+ */
+ @Override
+ public int[][] getInt2Array() {
+ LOGGER.info("getInt2Array()");
+ int[][] res = new int[this.rowLength][];
+ int index = -1;
+ while (++index < this.rowLength) {
+ String[] strings = ASStr.splitByChar(scanner.nextLine(), sep);
+ int[] row = new int[strings.length];
+ int index_2 = -1;
+ for (String string : strings) {
+ row[++index_2] = Integer.parseInt(string);
+ }
+ res[index] = row;
+ }
+ return res;
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 int 拚菜唳殷銝祆萎嚗餈餈臭鈭拚萄蝝唳柴
+ *
+ * From the data input component, double matrix data is increasingly generated. Generally, some matrix element data is returned here.
+ *
+ * @return double[][]
+ */
+ @Override
+ public double[][] getDouble2Array() {
+ LOGGER.info("getDouble2Array()");
+ double[][] res = new double[this.rowLength][];
+ int index = -1;
+ while (++index < this.rowLength) {
+ String[] strings = ASStr.splitByChar(scanner.nextLine(), sep);
+ double[] row = new double[strings.length];
+ int index_2 = -1;
+ for (String string : strings) {
+ row[++index_2] = Double.parseDouble(string);
+ }
+ res[index] = row;
+ }
+ return res;
+ }
+
+ /**
+ * 隞唳株亦隞嗉瑕 DataFrame 撖寡情嚗霂亙賣唳鈭唳株亦隞嗅航賭舀
+ *
+ * Retrieve the DataFrame object from the data input component, which may not be supported by some data input components.
+ *
+ * @return 隞唳株亦隞嗡葉瑕啁DataFrame唳桀鋆撖寡情
+ *
+ * The DataFrame data encapsulation object obtained from the data input component.
+ */
+ @Override
+ public DataFrame getDataFrame() {
+ LOGGER.info("getDataFrame()");
+ DataFrame select = FDataFrame.select(
+ FieldCell.parse(ASStr.splitByChar(scanner.nextLine(), sep)), pk
+ );
+ int index = -1;
+ while (++index < this.rowLength) {
+ select.insert(FinalSeries.parse(ASStr.splitByChar(scanner.nextLine(), sep)));
+ }
+ return select;
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 唳格 撖寡情
+ *
+ * Extract the data flow object from the data input component.
+ *
+ * @return 唳株交撖寡情
+ */
+ @Override
+ public InputStream getInputStream() {
+ LOGGER.info("getInputStream()");
+ return inputStream;
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 曉蝻摮 撖寡情嚗閬瘜冽荔霂交雿冽鈭萎航賭鋡急舀
+ *
+ * Extracting image cache objects from the data input component, it should be noted that this operation may not be supported in some cases.
+ *
+ * @return 曉蝻摮撖寡情
+ */
+ @Override
+ public BufferedImage getBufferedImage() {
+ LOGGER.info("getBufferedImage()");
+ try {
+ return ImageIO.read(inputStream);
+ } catch (IOException e) {
+ throw new OperatorOperationException(e);
+ }
+ }
+
+ /**
+ * Closes this stream and releases any system resources associated
+ * with it. If the stream is already closed then invoking this
+ * method has no effect.
+ *
+ *
As noted in {@link AutoCloseable#close()}, cases where the
+ * close may fail require careful attention. It is strongly advised
+ * to relinquish the underlying resources and to internally
+ * mark the {@code Closeable} as closed, prior to throwing
+ * the {@code IOException}.
+ */
+ @Override
+ public void close() {
+ LOGGER.info("close()");
+ ASIO.close(this.scanner);
+ }
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/InputByStreamBuilder.java b/src_code/src/main/java/zhao/algorithmMagic/io/InputByStreamBuilder.java
new file mode 100644
index 0000000..d719be2
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/InputByStreamBuilder.java
@@ -0,0 +1,77 @@
+package zhao.algorithmMagic.io;
+
+import zhao.algorithmMagic.operands.table.Cell;
+import zhao.algorithmMagic.operands.table.FinalCell;
+import zhao.algorithmMagic.utils.ASClass;
+
+import java.util.HashMap;
+
+/**
+ * 唳格颲亥挽憭撖寡情撱粹蝐鳴刻砲蝐颱葉典臭誑撖寞唳格唳株交雿餈銵銝鈭蝵殷隞亥瑕唳唳格銝剔唳桀笆鞊∼
+ *
+ * The data flow input device object creator class allows you to configure the data input operations of the data flow to obtain the data objects in the data flow.
+ */
+public class InputByStreamBuilder extends HashMap> implements InputBuilder {
+
+ /**
+ * 唳株交
+ */
+ public final static String INPUT_STREAM = "ism";
+
+ /**
+ * 蝏唳桐閬鋡怨粉銵
+ */
+ public final static String ROW_LEN = "rc";
+
+ /**
+ * DF撖寡情霂餃銝剝閬霂餃銵
+ */
+ public final static String PK = "pk";
+
+ /**
+ * 唳株亦
+ */
+ public final static String CHARSET = "cs";
+
+ /**
+ * 蝏唳桐閬雿輻函蝚
+ */
+ public final static String SEP = "sep";
+
+ /**
+ * 瘛餃唳株交餈堆銝蝏隞嗆銝蝵桀改瑚臭誑摰啁掩
+ *
+ * Add data input descriptions, and different components have different configuration properties. Please refer to the implementation class for details.
+ *
+ * @param key 撅批蝘
+ *
+ * Attribute Name.
+ * @param value 撅扳啣
+ *
+ * Attribute Value.
+ * @return 曉靚剁蝏抒賒撱
+ *
+ * Chain call, continue building.
+ */
+ @Override
+ public InputBuilder addInputArg(String key, FinalCell> value) {
+ this.put(key, value);
+ return this;
+ }
+
+ /**
+ * 撠撖寡情撱箏箸亙僎瑕啣笆摨颲亥挽憭撖寡情
+ *
+ * @return 颲亥挽憭撖寡情
+ */
+ @Override
+ public InputComponent create() {
+ return new InputByStream(
+ ASClass.transform(this.get(INPUT_STREAM)),
+ ASClass.transform(this.get(CHARSET)),
+ this.getOrDefault(ROW_LEN, new FinalCell<>(10)).getIntValue(),
+ this.getOrDefault(PK, new FinalCell<>(0)).getIntValue(),
+ ASClass.| , Cell>transform(this.getOrDefault(SEP, new FinalCell<>(','))).getValue()
+ );
+ }
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/InputCamera.java b/src_code/src/main/java/zhao/algorithmMagic/io/InputCamera.java
new file mode 100644
index 0000000..d98f7c2
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/InputCamera.java
@@ -0,0 +1,159 @@
+package zhao.algorithmMagic.io;
+
+import com.github.sarxos.webcam.Webcam;
+import com.github.sarxos.webcam.WebcamUtils;
+import zhao.algorithmMagic.exception.OperatorOperationException;
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.utils.ASClass;
+import zhao.algorithmMagic.utils.ASIO;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * 憭游笆鞊∴其隞憭湔銝撘曉
+ *
+ * @author 韏萄摰
+ * 2023/4/5 13:51
+ */
+public class InputCamera implements InputComponent {
+
+ private final Webcam webcam;
+ private final String format;
+
+ /**
+ * @param webcam 批笆鞊
+ * @param format 找曉澆
+ */
+ protected InputCamera(Webcam webcam, String format) {
+ this.webcam = webcam;
+ this.format = format;
+ }
+
+ /**
+ * @return 撘憪撱箸祆唳桃隞嗅笆鞊∼
+ *
+ * Start building this data component object.
+ */
+ public static InputBuilder builder() {
+ return new InputCameraBuilder();
+ }
+
+ /**
+ * 臬冽唳株亦隞
+ *
+ * @return 憒臬冽餈true
+ */
+ @Override
+ public boolean open() {
+ return webcam.open();
+ }
+
+ /**
+ * @return 憒蝏隞嗅歇蝏臬其嚗刻餈true
+ */
+ @Override
+ public boolean isOpen() {
+ return webcam.isOpen();
+ }
+
+ /**
+ * 喲剜唳株亦隞
+ */
+ @Override
+ public void close() {
+ webcam.close();
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 byte 啁唳殷銝祆萎嚗餈餈賣臭鈭鈭餈嗥唳柴
+ *
+ * Extract the data of the byte array from the data input component. Generally, the returned data here is some binary data.
+ *
+ * @return byte[] 唳桀笆鞊
+ */
+ @Override
+ public byte[] getByteArray() {
+ return WebcamUtils.getImageBytes(webcam, format);
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 int 拚菜唳殷銝祆萎嚗餈餈臭鈭拚萄蝝唳柴
+ *
+ * From the data input component, int matrix data is increasingly generated. Generally, some matrix element data is returned here.
+ *
+ * @return int[][]
+ */
+ @Override
+ public int[][] getInt2Array() {
+ return ASIO.parseImageGetArray(this.getBufferedImage());
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 int 拚菜唳殷銝祆萎嚗餈餈臭鈭拚萄蝝唳柴
+ *
+ * From the data input component, double matrix data is increasingly generated. Generally, some matrix element data is returned here.
+ *
+ * @return double[][]
+ */
+ @Override
+ public double[][] getDouble2Array() {
+ int[][] int2Array = this.getInt2Array();
+ double[][] res = new double[int2Array.length][];
+ int index = -1;
+ for (int[] ints : int2Array) {
+ res[++index] = ASClass.IntArray_To_DoubleArray(ints);
+ }
+ return res;
+ }
+
+ /**
+ * 隞唳株亦隞嗉瑕 DataFrame 撖寡情嚗霂亙賣唳鈭唳株亦隞嗅航賭舀
+ *
+ * Retrieve the DataFrame object from the data input component, which may not be supported by some data input components.
+ *
+ * @return 隞唳株亦隞嗡葉瑕啁DataFrame唳桀鋆撖寡情
+ *
+ * The DataFrame data encapsulation object obtained from the data input component.
+ */
+ @Override
+ public DataFrame getDataFrame() {
+ throw new UnsupportedOperationException("豢箄挽憭銝舀瑕蚤ataFrame撖寡情\nThe camera device does not support obtaining DataFrame objects.");
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 唳格 撖寡情
+ *
+ * Extract the data flow object from the data input component.
+ *
+ * @return 唳株交撖寡情
+ */
+ @Override
+ public InputStream getInputStream() {
+ return new ByteArrayInputStream(this.getByteArray());
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 曉蝻摮 撖寡情嚗閬瘜冽荔霂交雿冽鈭萎航賭鋡急舀
+ *
+ * Extracting image cache objects from the data input component, it should be noted that this operation may not be supported in some cases.
+ *
+ * @return 曉蝻摮撖寡情
+ */
+ @Override
+ public BufferedImage getBufferedImage() {
+ InputStream inputStream = null;
+ try {
+ inputStream = this.getInputStream();
+ return ImageIO.read(inputStream);
+ } catch (IOException e) {
+ throw new OperatorOperationException("抒豢箸扯粉憭梯揖.Camera photo reading failed.", e);
+ } finally {
+ ASIO.close(inputStream);
+ }
+ }
+
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/InputCameraBuilder.java b/src_code/src/main/java/zhao/algorithmMagic/io/InputCameraBuilder.java
new file mode 100644
index 0000000..3eebc7a
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/InputCameraBuilder.java
@@ -0,0 +1,94 @@
+package zhao.algorithmMagic.io;
+
+import com.github.sarxos.webcam.Webcam;
+import com.github.sarxos.webcam.WebcamResolution;
+import zhao.algorithmMagic.exception.OperatorOperationException;
+import zhao.algorithmMagic.operands.table.Cell;
+import zhao.algorithmMagic.operands.table.FinalCell;
+
+import java.util.HashMap;
+
+/**
+ * 憭渲挽憭颲亙遣撖寡情
+ *
+ * @author 韏萄摰
+ * 2023/4/5 14:28
+ */
+public class InputCameraBuilder extends HashMap> implements InputBuilder {
+
+ /**
+ * 扳園閬雿輻函憭渡揣撘嚗蝝W撖孵value摨臭銝芣啣潭摮蝚虫葡嚗憒嗆啣澆敶雿蝝W憭嚗憒嗅蝚虫葡撠敶雿憭游蝘啣
+ */
+ public final static String Camera_Index = "Camera";
+
+ /**
+ * 扳園閬雿輻函曉扳澆嚗澆撖孵澆臭銝芸蝚虫葡
+ */
+ public final static String Image_Format = "ImageFormat";
+
+ /**
+ * 曉批之撠撠箏站撖寡情嚗澆撖孵澆臭誑湔交 WebcamResolution 蝐餌撅扼
+ */
+ public final static String CUSTOM_VIEW_SIZES = "CustomViewSizes";
+
+ public WebcamResolution webcamResolution = WebcamResolution.VGA;
+
+ /**
+ * 瘛餃唳株交餈堆銝蝏隞嗆銝蝵桀改瑚臭誑摰啁掩
+ *
+ * Add data input descriptions, and different components have different configuration properties. Please refer to the implementation class for details.
+ *
+ * @param key 撅批蝘
+ *
+ * Attribute Name.
+ * @param value 撅扳啣
+ *
+ * Attribute Value.
+ * @return 曉靚剁蝏抒賒撱
+ *
+ * Chain call, continue building.
+ */
+ @Override
+ public InputBuilder addInputArg(String key, FinalCell> value) {
+ if (CUSTOM_VIEW_SIZES.equals(key)) {
+ return this.setViewSize(WebcamResolution.valueOf(value.toString()));
+ }
+ this.put(key, value);
+ return this;
+ }
+
+ /**
+ * @param WebcamResolution 曉批之撠撠箏站撖寡情
+ * @return 曉靚剁蝏抒賒撱
+ *
+ * Chain call, continue building.
+ */
+ public InputBuilder setViewSize(WebcamResolution WebcamResolution) {
+ this.webcamResolution = WebcamResolution;
+ return this;
+ }
+
+ /**
+ * 撠撖寡情撱箏箸亙僎瑕啣笆摨颲亥挽憭撖寡情
+ *
+ * @return 颲亥挽憭撖寡情
+ */
+ @Override
+ public InputComponent create() {
+ Cell> cell = this.get(Camera_Index);
+ Webcam webcam;
+ if (cell != null) {
+ if (cell.isNumber()) {
+ webcam = Webcam.getWebcams().get(cell.getIntValue());
+ } else {
+ String s = cell.toString();
+ if ("def".equals(s)) webcam = Webcam.getDefault();
+ else webcam = Webcam.getWebcamByName(s);
+ }
+ webcam.setViewSize(this.webcamResolution.getSize());
+ return new InputCamera(webcam, this.getOrDefault(Image_Format, new FinalCell<>("JPG")).toString());
+ } else {
+ throw new OperatorOperationException("霂瑟券蝵格憭渡蝘唳憭渡揣撘\nPlease configure the name or camera index of the camera.");
+ }
+ }
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/InputComponent.java b/src_code/src/main/java/zhao/algorithmMagic/io/InputComponent.java
new file mode 100644
index 0000000..90c7069
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/InputComponent.java
@@ -0,0 +1,88 @@
+package zhao.algorithmMagic.io;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+
+import java.awt.image.BufferedImage;
+import java.io.Closeable;
+import java.io.InputStream;
+
+/**
+ * IO蝏隞嗅笆鞊∴霂亙笆鞊⊥舀唳株亥挽憭嗥掩亙撖寡情嚗餈霂亙笆鞊∪臭誑摰啗瑕啁洵銝寞唳桃雿
+ *
+ * IO component object, which is the parent interface object of all data input devices, through which the operation of obtaining third-party data can be achieved
+ *
+ * @author 韏萄摰
+ * 2023/4/5 13:52
+ */
+public interface InputComponent extends Closeable {
+
+ /**
+ * 臬冽唳株亦隞
+ *
+ * @return 憒臬冽餈true
+ */
+ boolean open();
+
+ /**
+ * @return 憒蝏隞嗅歇蝏臬其嚗刻餈true
+ *
+ * If the component has already started, return true here.
+ */
+ boolean isOpen();
+
+ /**
+ * 隞唳株亦隞嗡葉 byte 啁唳殷銝祆萎嚗餈餈賣臭鈭鈭餈嗥唳柴
+ *
+ * Extract the data of the byte array from the data input component. Generally, the returned data here is some binary data.
+ *
+ * @return byte[] 唳桀笆鞊
+ */
+ byte[] getByteArray();
+
+ /**
+ * 隞唳株亦隞嗡葉 int 拚菜唳殷銝祆萎嚗餈餈臭鈭拚萄蝝唳柴
+ *
+ * From the data input component, int matrix data is increasingly generated. Generally, some matrix element data is returned here.
+ *
+ * @return int[][]
+ */
+ int[][] getInt2Array();
+
+ /**
+ * 隞唳株亦隞嗡葉 int 拚菜唳殷銝祆萎嚗餈餈臭鈭拚萄蝝唳柴
+ *
+ * From the data input component, double matrix data is increasingly generated. Generally, some matrix element data is returned here.
+ *
+ * @return double[][]
+ */
+ double[][] getDouble2Array();
+
+ /**
+ * 隞唳株亦隞嗉瑕 DataFrame 撖寡情嚗霂亙賣唳鈭唳株亦隞嗅航賭舀
+ *
+ * Retrieve the DataFrame object from the data input component, which may not be supported by some data input components.
+ *
+ * @return 隞唳株亦隞嗡葉瑕啁DataFrame唳桀鋆撖寡情
+ *
+ * The DataFrame data encapsulation object obtained from the data input component.
+ */
+ DataFrame getDataFrame();
+
+ /**
+ * 隞唳株亦隞嗡葉 唳格 撖寡情
+ *
+ * Extract the data flow object from the data input component.
+ *
+ * @return 唳株交撖寡情
+ */
+ InputStream getInputStream();
+
+ /**
+ * 隞唳株亦隞嗡葉 曉蝻摮 撖寡情嚗閬瘜冽荔霂交雿冽鈭萎航賭鋡急舀
+ *
+ * Extracting image cache objects from the data input component, it should be noted that this operation may not be supported in some cases.
+ *
+ * @return 曉蝻摮撖寡情
+ */
+ BufferedImage getBufferedImage();
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/InputHDFS.java b/src_code/src/main/java/zhao/algorithmMagic/io/InputHDFS.java
new file mode 100644
index 0000000..7f793d8
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/InputHDFS.java
@@ -0,0 +1,216 @@
+package zhao.algorithmMagic.io;
+
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import zhao.algorithmMagic.exception.OperatorOperationException;
+import zhao.algorithmMagic.operands.table.*;
+import zhao.algorithmMagic.utils.ASIO;
+import zhao.algorithmMagic.utils.ASStr;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.*;
+
+/**
+ * HDFS唳株亦隞嗅笆鞊∴賢隞HDFS撟喳唬葉瑕唳隞嗆唳柴
+ *
+ * HDFS data input component object, which can obtain file data from the HDFS platform.
+ *
+ * @author 韏萄摰
+ * 2023/4/6 8:40
+ */
+public class InputHDFS implements InputComponent {
+
+ private final static Logger LOGGER = LoggerFactory.getLogger("InputHDFS");
+ private final FileSystem fileSystem;
+ private final Path inputPath;
+ private final char sep;
+ private final String charset;
+ private final Series field;
+ private final int pk;
+ private FSDataInputStream fsDataInputStream;
+ private BufferedReader bufferedReader;
+ private boolean isOpen;
+
+ /**
+ * @param fileSystem HDFS 隞嗥頂蝏撖寡情
+ * @param inputPath 閬鋡怨粉隞嗉楝敺
+ * @param sep 霂餃園閬雿輻函蝚
+ * @param charset 霂餃園閬雿輻典蝚阡
+ * @param field 霂餃嗥銵典畾萄蝘啗
+ * @param pk 霂餃嗥銵其蜓桀笆鞊
+ */
+ protected InputHDFS(FileSystem fileSystem, Path inputPath, char sep, String charset, Cell field, int pk) {
+ if (fileSystem == null || inputPath == null || field == null) {
+ throw new OperatorOperationException("The parameter in [FileSystem fileSystem, Path inputPath, String[] field] cannot be null!!!!");
+ }
+ this.fileSystem = fileSystem;
+ this.inputPath = inputPath;
+ this.sep = sep;
+ this.charset = charset;
+ this.field = FieldCell.parse(field.getValue());
+ this.pk = pk;
+ this.isOpen = false;
+ }
+
+ /**
+ * @return 撘憪撱箸祆唳桃隞嗅笆鞊∼
+ *
+ * Start building this data component object.
+ */
+ public static InputBuilder builder() {
+ return new InputHDFSBuilder();
+ }
+
+ /**
+ * 臬冽唳株亦隞
+ *
+ * @return 憒臬冽餈true
+ */
+ @Override
+ public boolean open() {
+ try {
+ LOGGER.info("InputHDFS.open()");
+ this.fsDataInputStream = fileSystem.open(this.inputPath);
+ this.bufferedReader = new BufferedReader(new InputStreamReader(fsDataInputStream));
+ return true;
+ } catch (IOException e) {
+ LOGGER.error("InputHDFS.open() error!!!", e);
+ return false;
+ }
+ }
+
+ /**
+ * @return 憒蝏隞嗅歇蝏臬其嚗刻餈true
+ */
+ @Override
+ public boolean isOpen() {
+ LOGGER.info("InputHDFS.isOpen()");
+ return this.isOpen;
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 byte 啁唳殷銝祆萎嚗餈餈賣臭鈭鈭餈嗥唳柴
+ *
+ * Extract the data of the byte array from the data input component. Generally, the returned data here is some binary data.
+ *
+ * @return byte[] 唳桀笆鞊
+ */
+ @Override
+ public byte[] getByteArray() {
+ LOGGER.info("getByteArray()");
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ try {
+ while (bufferedReader.ready()) {
+ byteArrayOutputStream.write(bufferedReader.readLine().getBytes(charset));
+ }
+ return byteArrayOutputStream.toByteArray();
+ } catch (IOException e) {
+ throw new OperatorOperationException(e);
+ } finally {
+ ASIO.close(byteArrayOutputStream);
+ }
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 int 拚菜唳殷銝祆萎嚗餈餈臭鈭拚萄蝝唳柴
+ *
+ * From the data input component, int matrix data is increasingly generated. Generally, some matrix element data is returned here.
+ *
+ * @return int[][]
+ */
+ @Override
+ public int[][] getInt2Array() {
+ LOGGER.info("getInt2Array()");
+ LOGGER.warn("Not currently supported getInt2Array()!!!");
+ return new int[0][];
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 int 拚菜唳殷銝祆萎嚗餈餈臭鈭拚萄蝝唳柴
+ *
+ * From the data input component, double matrix data is increasingly generated. Generally, some matrix element data is returned here.
+ *
+ * @return double[][]
+ */
+ @Override
+ public double[][] getDouble2Array() {
+ LOGGER.info("getDouble2Array()");
+ LOGGER.warn("Not currently supported getDouble2Array()!!!");
+ return new double[0][];
+ }
+
+ /**
+ * 隞唳株亦隞嗉瑕 DataFrame 撖寡情嚗霂亙賣唳鈭唳株亦隞嗅航賭舀
+ *
+ * Retrieve the DataFrame object from the data input component, which may not be supported by some data input components.
+ *
+ * @return 隞唳株亦隞嗡葉瑕啁DataFrame唳桀鋆撖寡情
+ *
+ * The DataFrame data encapsulation object obtained from the data input component.
+ */
+ @Override
+ public DataFrame getDataFrame() {
+ LOGGER.info("getDataFrame()");
+ DataFrame select = FDataFrame.select(this.field, pk);
+ try {
+ while (bufferedReader.ready()) {
+ select.insert(FinalSeries.parse(ASStr.splitByChar(bufferedReader.readLine(), sep)));
+ }
+ return select;
+ } catch (IOException e) {
+ throw new OperatorOperationException(e);
+ }
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 唳格 撖寡情
+ *
+ * Extract the data flow object from the data input component.
+ *
+ * @return 唳株交撖寡情
+ */
+ @Override
+ public InputStream getInputStream() {
+ LOGGER.info("getInputStream()");
+ return this.fsDataInputStream;
+ }
+
+ /**
+ * 隞唳株亦隞嗡葉 曉蝻摮 撖寡情嚗閬瘜冽荔霂交雿冽鈭萎航賭鋡急舀
+ *
+ * Extracting image cache objects from the data input component, it should be noted that this operation may not be supported in some cases.
+ *
+ * @return 曉蝻摮撖寡情
+ */
+ @Override
+ public BufferedImage getBufferedImage() {
+ LOGGER.info("getBufferedImage()");
+ try {
+ return ImageIO.read(this.fsDataInputStream);
+ } catch (IOException e) {
+ throw new OperatorOperationException(e);
+ }
+ }
+
+ /**
+ * Closes this stream and releases any system resources associated
+ * with it. If the stream is already closed then invoking this
+ * method has no effect.
+ *
+ * As noted in {@link AutoCloseable#close()}, cases where the
+ * close may fail require careful attention. It is strongly advised
+ * to relinquish the underlying resources and to internally
+ * mark the {@code Closeable} as closed, prior to throwing
+ * the {@code IOException}.
+ */
+ @Override
+ public void close() {
+ LOGGER.info("close()");
+ ASIO.close(this.bufferedReader);
+ isOpen = false;
+ }
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/InputHDFSBuilder.java b/src_code/src/main/java/zhao/algorithmMagic/io/InputHDFSBuilder.java
new file mode 100644
index 0000000..9c9a325
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/InputHDFSBuilder.java
@@ -0,0 +1,88 @@
+package zhao.algorithmMagic.io;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import zhao.algorithmMagic.operands.table.Cell;
+import zhao.algorithmMagic.operands.table.FinalCell;
+import zhao.algorithmMagic.utils.ASClass;
+
+import java.util.HashMap;
+
+/**
+ * HDFS唳株亦隞嗅遣撖寡情嚗刻砲撖寡情銝剛賢銝慵DFS唳株亦隞嗉銵撱箝
+ *
+ * HDFS data input component object, which can obtain file data from the HDFS platform.
+ *
+ * @author 韏萄摰
+ * 2023/4/6 9:18
+ */
+public class InputHDFSBuilder extends HashMap> implements InputBuilder {
+
+ /**
+ * HDFS隞嗥頂蝏撖寡情
+ */
+ public final static String FILE_SYSTEM = "FS";
+
+ /**
+ * 唳桀頧賢蝚
+ */
+ public final static String SEP = "sep";
+
+ /**
+ * 唳株亥楝敺
+ */
+ public final static String IN_PATH = "inPath";
+
+ /**
+ * 唳株亙蝚阡
+ */
+ public final static String CHAR_SET = "cs";
+
+ /**
+ * 唳株乩蜓
+ */
+ public final static String PK = "pk";
+
+ /**
+ * 唳桀蝚血蝘
+ */
+ public final static String FIELD = "field";
+
+ /**
+ * 瘛餃唳株交餈堆銝蝏隞嗆銝蝵桀改瑚臭誑摰啁掩
+ *
+ * Add data input descriptions, and different components have different configuration properties. Please refer to the implementation class for details.
+ *
+ * @param key 撅批蝘
+ *
+ * Attribute Name.
+ * @param value 撅扳啣
+ *
+ * Attribute Value.
+ * @return 曉靚剁蝏抒賒撱
+ *
+ * Chain call, continue building.
+ */
+ @Override
+ public InputBuilder addInputArg(String key, FinalCell> value) {
+ this.put(key, value);
+ return this;
+ }
+
+ /**
+ * 撠撖寡情撱箏箸亙僎瑕啣笆摨颲亥挽憭撖寡情
+ *
+ * @return 颲亥挽憭撖寡情
+ */
+ @Override
+ public InputComponent create() {
+ return new InputHDFS(
+ (FileSystem) this.get(FILE_SYSTEM).getValue(),
+ new Path(this.get(IN_PATH).toString()),
+ ASClass., Cell>transform(this.getOrDefault(SEP, new FinalCell<>(','))).getValue(),
+ this.getOrDefault(CHAR_SET, new FinalCell<>("utf-8")).toString(),
+ ASClass.| , Cell>transform(this.get(FIELD)),
+ this.getOrDefault(PK, new FinalCell<>(0)).getIntValue()
+ );
+ }
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/OutputBuilder.java b/src_code/src/main/java/zhao/algorithmMagic/io/OutputBuilder.java
new file mode 100644
index 0000000..519cfc1
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/OutputBuilder.java
@@ -0,0 +1,37 @@
+package zhao.algorithmMagic.io;
+
+import zhao.algorithmMagic.operands.table.FinalCell;
+
+/**
+ * 唳株箇隞嗅遣蝐鳴梯砲蝐餃遣箸唳株箇隞嗅笆鞊∼
+ *
+ * The data output component builder class, which constructs effective data output component objects.
+ *
+ * @author 韏萄摰
+ * 2023/4/6 19:32
+ */
+public interface OutputBuilder {
+ /**
+ * 瘛餃唳株交餈堆銝蝏隞嗆銝蝵桀改瑚臭誑摰啁掩
+ *
+ * Add data input descriptions, and different components have different configuration properties. Please refer to the implementation class for details.
+ *
+ * @param key 撅批蝘
+ *
+ * Attribute Name.
+ * @param value 撅扳啣
+ *
+ * Attribute Value.
+ * @return 曉靚剁蝏抒賒撱
+ *
+ * Chain call, continue building.
+ */
+ OutputBuilder addOutputArg(String key, FinalCell> value);
+
+ /**
+ * 撠撖寡情撱箏箸亙僎瑕啣笆摨颲亥挽憭撖寡情
+ *
+ * @return 颲亥挽憭撖寡情
+ */
+ OutputComponent create();
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/OutputComponent.java b/src_code/src/main/java/zhao/algorithmMagic/io/OutputComponent.java
new file mode 100644
index 0000000..e12dcec
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/OutputComponent.java
@@ -0,0 +1,80 @@
+package zhao.algorithmMagic.io;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+import zhao.algorithmMagic.operands.matrix.ColumnDoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.ColumnIntegerMatrix;
+import zhao.algorithmMagic.operands.table.DataFrame;
+
+import java.io.Closeable;
+
+/**
+ * 唳株箄挽憭蝐鳴甇斤掩銝剖急唳株粹餉摰堆臭誑餈甇斗亙湔亙唳株箏啁洵銝孵像啜
+ *
+ * Data output device class, which includes data output logic implementation, can directly output data to third-party platforms through this interface.
+ *
+ * @author 韏萄摰
+ * 2023/4/6 19:35
+ */
+public interface OutputComponent extends Closeable {
+
+ /**
+ * 臬冽唳株箇隞.
+ *
+ * Start data output component.
+ *
+ * @return 憒臬冽餈true
+ */
+ boolean open();
+
+ /**
+ * @return 憒蝏隞嗅歇蝏臬其嚗刻餈true.
+ *
+ * If the component has already started, return true here
+ */
+ boolean isOpen();
+
+ /**
+ * 撠銝隞賭餈嗆唳株箝
+ *
+ * Output a binary data.
+ *
+ * @param data 閬鋡怨箇鈭餈嗆唳桀
+ *
+ * The binary data package that needs to be output.
+ */
+ void writeByteArray(byte[] data);
+
+ /**
+ * 颲箔銝 游耦 拚萄笆鞊
+ *
+ * @param matrix 閬鋡怨箇拚
+ */
+ void writeMat(ColumnIntegerMatrix matrix);
+
+ /**
+ * 颲箔銝 double蝐餃 拚萄笆鞊
+ *
+ * @param matrix 閬鋡怨箇拚
+ */
+ void writeMat(ColumnDoubleMatrix matrix);
+
+ /**
+ * 撠曉拚菜怎曉湔亥箏啁格
+ *
+ * Directly output the images contained in the image matrix to the target.
+ *
+ * @param colorMatrix 閬鋡怨箇曉拚萄笆鞊∼
+ *
+ * The image matrix object that needs to be output.
+ */
+ void writeImage(ColorMatrix colorMatrix);
+
+ /**
+ * 撠銝銝 DataFrame 銝剔唳格扳唳株箇隞嗉銵颲.
+ *
+ * Output the data in a DataFrame according to the data output component.
+ *
+ * @param dataFrame 閬鋡怨箇唳桀笆鞊
+ */
+ void writeDataFrame(DataFrame dataFrame);
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/OutputHDFS.java b/src_code/src/main/java/zhao/algorithmMagic/io/OutputHDFS.java
new file mode 100644
index 0000000..eb06c87
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/OutputHDFS.java
@@ -0,0 +1,252 @@
+package zhao.algorithmMagic.io;
+
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import zhao.algorithmMagic.exception.OperatorOperationException;
+import zhao.algorithmMagic.integrator.ImageRenderingIntegrator;
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+import zhao.algorithmMagic.operands.matrix.ColumnDoubleMatrix;
+import zhao.algorithmMagic.operands.matrix.ColumnIntegerMatrix;
+import zhao.algorithmMagic.operands.table.Cell;
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.Series;
+import zhao.algorithmMagic.utils.ASIO;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+/**
+ * HDFS 撟喳唳唳株箄挽憭蝐鳴刻砲蝐餌內靘箸亦撖寡情銝剛賢湔亙唳株箏蚜DFS隞嗥頂蝏銝准
+ *
+ * HDFS platform data output device class, which can directly output data to the HDFS file system in the instantiated objects of this class.
+ *
+ * @author 韏萄摰
+ * 2023/4/6 20:01
+ */
+public class OutputHDFS implements OutputComponent {
+
+ private final static Logger LOGGER = LoggerFactory.getLogger("OutputHDFS");
+
+
+ private final FileSystem fileSystem;
+ private final Path outputPath;
+ private final String format;
+ private final char sep;
+ private boolean isOpen = false;
+ private FSDataOutputStream fsDataOutputStream;
+ private BufferedWriter bufferedWriter;
+
+ /**
+ * @param fileSystem HDFS 隞嗥頂蝏撖寡情
+ *
+ * HDFS File System Objects.
+ * @param outputPath HDFS 隞嗆唳株箇桀
+ *
+ * HDFS file data output directory.
+ * @param format HDFS 隞嗆唳株箸澆
+ *
+ * HDFS file data output format.
+ * @param sep 隞嗆唳株箸園閬雿輻函蝚艾
+ *
+ * Delimiters required for file data output.
+ */
+ public OutputHDFS(FileSystem fileSystem, Path outputPath, String format, char sep) {
+ if (fileSystem == null || outputPath == null || format == null) {
+ throw new OperatorOperationException("The parameter in [FileSystem fileSystem, Path outputPath, String format] cannot be null!!!!");
+ }
+ this.fileSystem = fileSystem;
+ this.outputPath = outputPath;
+ this.format = format;
+ this.sep = sep;
+ }
+
+ public static OutputBuilder builder() {
+ return new OutputHDFSBuidler();
+ }
+
+ /**
+ * 臬冽唳株箇隞.
+ *
+ * Start data output component.
+ *
+ * @return 憒臬冽餈true
+ */
+ @Override
+ public boolean open() {
+ try {
+ LOGGER.info("OutputHDFS.open()");
+ fsDataOutputStream = fileSystem.create(outputPath);
+ bufferedWriter = new BufferedWriter(new OutputStreamWriter(fsDataOutputStream));
+ this.isOpen = true;
+ return true;
+ } catch (IOException e) {
+ LOGGER.error("OutputHDFS.open() error!!!", e);
+ return false;
+ }
+ }
+
+ /**
+ * @return 憒蝏隞嗅歇蝏臬其嚗刻餈true.
+ *
+ * If the component has already started, return true here
+ */
+ @Override
+ public boolean isOpen() {
+ LOGGER.info("OutputHDFS.isOpen()");
+ return this.isOpen;
+ }
+
+ /**
+ * 撠銝隞賭餈嗆唳株箝
+ *
+ * Output a binary data.
+ *
+ * @param data 閬鋡怨箇鈭餈嗆唳桀
+ *
+ * The binary data package that needs to be output.
+ */
+ @Override
+ public void writeByteArray(byte[] data) {
+ LOGGER.info("writeByteArray(byte[] data)");
+ try {
+ fsDataOutputStream.write(data);
+ } catch (IOException e) {
+ throw new OperatorOperationException(e);
+ }
+ }
+
+ /**
+ * 颲箔銝 游耦 拚萄笆鞊
+ *
+ * @param matrix 閬鋡怨箇拚
+ */
+ @Override
+ public void writeMat(ColumnIntegerMatrix matrix) {
+ int rowCount = -1;
+ try {
+ // 颲箏
+ bufferedWriter.write("colName");
+ String[] rowFieldNames = matrix.getRowFieldNames();
+ for (String colName : matrix.getColFieldNames()) {
+ bufferedWriter.write(sep);
+ bufferedWriter.write(colName);
+ }
+ bufferedWriter.newLine();
+ for (int[] ints : matrix.toArrays()) {
+ bufferedWriter.write(rowFieldNames[++rowCount]);
+ for (int aInt : ints) {
+ bufferedWriter.write(sep);
+ bufferedWriter.write(String.valueOf(aInt));
+ }
+ }
+ } catch (IOException e) {
+ throw new OperatorOperationException("Write data exception!", e);
+ }
+ }
+
+ /**
+ * 颲箔銝 double蝐餃 拚萄笆鞊
+ *
+ * @param matrix 閬鋡怨箇拚
+ */
+ @Override
+ public void writeMat(ColumnDoubleMatrix matrix) {
+ int rowCount = -1;
+ try {
+ // 颲箏
+ bufferedWriter.write("colName");
+ String[] rowFieldNames = matrix.getRowFieldNames();
+ for (String colName : matrix.getColFieldNames()) {
+ bufferedWriter.write(sep);
+ bufferedWriter.write(colName);
+ }
+ bufferedWriter.newLine();
+ for (double[] ints : matrix.toArrays()) {
+ bufferedWriter.write(rowFieldNames[++rowCount]);
+ for (double aInt : ints) {
+ bufferedWriter.write(sep);
+ bufferedWriter.write(String.valueOf(aInt));
+ }
+ }
+ } catch (IOException e) {
+ throw new OperatorOperationException("Write data exception!", e);
+ }
+ }
+
+ /**
+ * 撠曉拚菜怎曉湔亥箏啁格
+ *
+ * Directly output the images contained in the image matrix to the target.
+ *
+ * @param colorMatrix 閬鋡怨箇曉拚萄笆鞊∼
+ *
+ * The image matrix object that needs to be output.
+ */
+ @Override
+ public void writeImage(ColorMatrix colorMatrix) {
+ LOGGER.info("writeImage(ColorMatrix colorMatrix)");
+ BufferedImage bufferedImage = ImageRenderingIntegrator.drawBufferedImage(
+ colorMatrix.toArrays(), colorMatrix.getColCount(), colorMatrix.getRowCount(), 1, false
+ );
+ try {
+ ImageIO.write(bufferedImage, format, fsDataOutputStream);
+ } catch (IOException e) {
+ throw new OperatorOperationException(e);
+ }
+ }
+
+ /**
+ * 撠銝銝 DataFrame 銝剔唳格扳唳株箇隞嗉銵颲.
+ *
+ * Output the data in a DataFrame according to the data output component.
+ *
+ * @param dataFrame 閬鋡怨箇唳桀笆鞊
+ */
+ @Override
+ public void writeDataFrame(DataFrame dataFrame) {
+ LOGGER.info("writeDataFrame(DataFrame dataFrame)");
+ try {
+ bufferedWriter.write("rowNumber");
+ for (Cell> cell : dataFrame.getFields()) {
+ bufferedWriter.write(sep);
+ bufferedWriter.write(cell.getStringValue());
+ }
+ bufferedWriter.newLine();
+ int count = 0;
+ for (Series cells : dataFrame) {
+ bufferedWriter.write(String.valueOf(++count));
+ for (Cell> cell : cells) {
+ bufferedWriter.write(sep);
+ bufferedWriter.write(cell.toString());
+ }
+ bufferedWriter.newLine();
+ }
+ } catch (IOException e) {
+ throw new OperatorOperationException(e);
+ }
+ }
+
+ /**
+ * Closes this stream and releases any system resources associated
+ * with it. If the stream is already closed then invoking this
+ * method has no effect.
+ *
+ * As noted in {@link AutoCloseable#close()}, cases where the
+ * close may fail require careful attention. It is strongly advised
+ * to relinquish the underlying resources and to internally
+ * mark the {@code Closeable} as closed, prior to throwing
+ * the {@code IOException}.
+ */
+ @Override
+ public void close() {
+ LOGGER.info("close()");
+ ASIO.close(this.bufferedWriter);
+ ASIO.close(this.fsDataOutputStream);
+ }
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/io/OutputHDFSBuidler.java b/src_code/src/main/java/zhao/algorithmMagic/io/OutputHDFSBuidler.java
new file mode 100644
index 0000000..faf93fc
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/io/OutputHDFSBuidler.java
@@ -0,0 +1,78 @@
+package zhao.algorithmMagic.io;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import zhao.algorithmMagic.operands.table.Cell;
+import zhao.algorithmMagic.operands.table.FinalCell;
+import zhao.algorithmMagic.utils.ASClass;
+
+import java.util.HashMap;
+
+/**
+ * HDFS唳株箄挽憭撱粹蝐鳴餈霂亦掩撱粹箸以DFS唳株箇內靘
+ *
+ * The builder class of HDFS data output devices, through which HDFS data output examples are constructed.
+ *
+ * @author 韏萄摰
+ * 2023/4/6 20:01
+ */
+public class OutputHDFSBuidler extends HashMap> implements OutputBuilder {
+
+ /**
+ * HDFS隞嗥頂蝏撖寡情
+ */
+ public final static String FILE_SYSTEM = "FS";
+
+ /**
+ * 唳桀頧賢蝚
+ */
+ public final static String SEP = "sep";
+
+ /**
+ * 唳株箄楝敺
+ */
+ public final static String OUT_PATH = "outPath";
+
+ /**
+ * 唳株箸嗥澆嚗桀舀銵典銝蝷
+ * 祆唳殷csv
+ * 曉唳殷Java舀曉澆
+ */
+ public final static String FORMAT = "format";
+
+ /**
+ * 瘛餃唳株交餈堆銝蝏隞嗆銝蝵桀改瑚臭誑摰啁掩
+ *
+ * Add data input descriptions, and different components have different configuration properties. Please refer to the implementation class for details.
+ *
+ * @param key 撅批蝘
+ *
+ * Attribute Name.
+ * @param value 撅扳啣
+ *
+ * Attribute Value.
+ * @return 曉靚剁蝏抒賒撱
+ *
+ * Chain call, continue building.
+ */
+ @Override
+ public OutputBuilder addOutputArg(String key, FinalCell> value) {
+ this.put(key, value);
+ return this;
+ }
+
+ /**
+ * 撠撖寡情撱箏箸亙僎瑕啣笆摨颲亥挽憭撖寡情
+ *
+ * @return 颲亥挽憭撖寡情
+ */
+ @Override
+ public OutputComponent create() {
+ return new OutputHDFS(
+ (FileSystem) this.get(FILE_SYSTEM).getValue(),
+ (Path) this.get(OUT_PATH).getValue(),
+ this.get(FORMAT).toString(),
+ ASClass.| , Cell>transform(this.getOrDefault(SEP, new FinalCell<>(','))).getValue()
+ );
+ }
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColorMatrix.java b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColorMatrix.java
index 3c59103..8532b36 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColorMatrix.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColorMatrix.java
@@ -1,19 +1,28 @@
package zhao.algorithmMagic.operands.matrix;
+import zhao.algorithmMagic.algorithm.distanceAlgorithm.DistanceAlgorithm;
import zhao.algorithmMagic.exception.OperatorOperationException;
import zhao.algorithmMagic.integrator.ImageRenderingIntegrator;
+import zhao.algorithmMagic.io.InputComponent;
+import zhao.algorithmMagic.io.OutputComponent;
+import zhao.algorithmMagic.operands.coordinate.IntegerCoordinateTwo;
import zhao.algorithmMagic.operands.matrix.block.IntegerMatrixSpace;
+import zhao.algorithmMagic.operands.table.Cell;
+import zhao.algorithmMagic.utils.ASClass;
import zhao.algorithmMagic.utils.ASIO;
import zhao.algorithmMagic.utils.ASMath;
+import zhao.algorithmMagic.utils.filter.DoubleFiltering;
import zhao.algorithmMagic.utils.transformation.ManyTrans;
+import zhao.algorithmMagic.utils.transformation.ProTransForm;
import javax.swing.*;
import java.awt.*;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.net.URL;
-import java.util.Arrays;
-import java.util.Iterator;
+import java.util.*;
+import java.util.function.Consumer;
/**
* 憸脩拚萄笆鞊∴嗡葉摮函瘥銝銝芸蝝賣臭銝 Color 撖寡情嚗冽亥銵曉蝏嗥撌乩
@@ -74,6 +83,217 @@ public class ColorMatrix extends Matrix
+ * The processing logic in the color value difference calculation scheme is to take 0 or 255 if the value exceeds the range, and take the value itself if the value does not exceed the range, achieving an efficient calculation scheme for limiting color values.
+ */
+ public final static ManyTrans COLOR_DIFF_REGULATE = (inputType1, inputType2) -> new Color(
+ ASMath.regularTricolor(inputType1.getRed() - inputType2.getRed()),
+ ASMath.regularTricolor(inputType1.getGreen() - inputType2.getGreen()),
+ ASMath.regularTricolor(inputType1.getBlue() - inputType2.getGreen())
+ );
+
+ /**
+ * 憸脫啣潭撌株恣蝞寞嚗刻砲寞銝剔憭餉銝綽憒x銝箸頞啣潘 x % 256 蝏雿銝粹脫啣潦
+ *
+ * The processing logic in the color value difference calculation scheme is: if x is the out-of-boundary value after the sum, the result of x% 256 is taken as the color value.
+ */
+ public final static ManyTrans COLOR_DIFF_REMAINDER = (inputType1, inputType2) -> {
+ int red = inputType1.getRed() - inputType2.getRed();
+ int green = inputType1.getGreen() - inputType2.getGreen();
+ int blue = inputType1.getBlue() - inputType2.getGreen();
+ return new Color(
+ red - (red >> _G_ << _G_),
+ green - (green >> _G_ << _G_),
+ blue - (blue >> _G_ << _G_)
+ );
+ };
+
+ /**
+ * 憸脫啣潭撌株恣蝞寞嚗刻砲寞銝剔憭餉銝箏啣潸箄湛0255嚗憒啣潭瓷頞餈游啣潭祈澈嚗摰圈脫啣潛擃嗥霈∠寞
+ *
+ * The processing logic in the color value difference calculation scheme is to take 0 or 255 if the value exceeds the range, and take the value itself if the value does not exceed the range, achieving an efficient calculation scheme for limiting color values.
+ */
+ public final static ManyTrans COLOR_DIFF_ABS = (inputType1, inputType2) -> new Color(
+ ASMath.absoluteValue(inputType1.getRed() - inputType2.getRed()),
+ ASMath.absoluteValue(inputType1.getGreen() - inputType2.getGreen()),
+ ASMath.absoluteValue(inputType1.getBlue() - inputType2.getGreen())
+ );
+
+ /**
+ * 憸脫啣潭蝘航恣蝞寞嚗刻砲寞銝剔憭餉銝箏啣潸箄湛0255嚗憒啣潭瓷頞餈游啣潭祈澈嚗摰圈脫啣潛擃嗥霈∠寞
+ *
+ * The processing logic in the color value quadrature calculation scheme is to take 0 or 255 if the value exceeds the range, and take the value itself if the value does not exceed the range, achieving an efficient calculation scheme for limiting color values.
+ */
+ public final static ManyTrans COLOR_MULTIPLY_REGULATE = (inputType1, inputType2) -> new Color(
+ ASMath.regularTricolor(inputType1.getRed() * inputType2.getRed()),
+ ASMath.regularTricolor(inputType1.getGreen() * inputType2.getGreen()),
+ ASMath.regularTricolor(inputType1.getBlue() * inputType2.getGreen())
+ );
+
+ /**
+ * 憸脫啣潭蝘航恣蝞寞嚗刻砲寞銝剔憭餉銝箏啣潸箄湛敶啣 % 256 蝏啣潔銝箏憸脫啣潦
+ *
+ * The processing logic in the color value quadrature calculation scheme is to take 0 or 255 if the value exceeds the range, and take the value itself if the value does not exceed the range, achieving an efficient calculation scheme for limiting color values.
+ */
+ public final static ManyTrans COLOR_MULTIPLY_REMAINDER = (inputType1, inputType2) -> {
+ int red = inputType1.getRed() + inputType2.getRed();
+ int green = inputType1.getGreen() + inputType2.getGreen();
+ int blue = inputType1.getBlue() + inputType2.getGreen();
+ return new Color(
+ red - (red >> _G_ << _G_),
+ green - (green >> _G_ << _G_),
+ blue - (blue >> _G_ << _G_)
+ );
+ };
+
+ /**
+ * 撠拚萎葉寡恣蝞銝綽 敶 = 喳 - 撌血
+ */
+ public final static Consumer CALCULATE_GRADIENT_RL = colors -> {
+ if (colors[0].length <= 2) return;
+ for (Color[] color : colors) {
+ Color left = color[0], right = color[2];
+ color[0] = color[1];
+ for (int i = 1, maxI = color.length - 2; i < maxI; ) {
+ Color now = right;
+ color[i] = COLOR_DIFF_REGULATE.function(right, left);
+ left = now;
+ right = color[++i];
+ }
+ }
+ };
+
+ /**
+ * 撠拚萎葉寡恣蝞銝綽 敶 = 銝 - 銝
+ */
+ public final static Consumer CALCULATE_GRADIENT_LH = colors -> {
+ if (colors.length <= 2) return;
+ Color[] back = colors[0], next = colors[2];
+ for (int i = 1, maxI = colors.length - 2; i < maxI; ) {
+ Color[] now1 = colors[i].clone();
+ Color[] now2 = next;
+ for (int index = 0; index < now2.length; index++) {
+ now2[index] = COLOR_DIFF_REGULATE.function(next[index], back[index]);
+ }
+ back = now1;
+ next = colors[++i];
+ }
+ };
+
+ /**
+ * 撠拚萎葉寡恣蝞銝綽 敶 = 喳 - 撌血
+ */
+ public final static Consumer CALCULATE_GRADIENT_RL_ABS = colors -> {
+ if (colors[0].length <= 2) return;
+ for (Color[] color : colors) {
+ Color left = color[0], right = color[2];
+ color[0] = color[1];
+ for (int i = 1, maxI = color.length - 2; i < maxI; ) {
+ Color now = right;
+ color[i] = COLOR_DIFF_ABS.function(right, left);
+ left = now;
+ right = color[++i];
+ }
+ }
+ };
+
+ /**
+ * 撠拚萎葉寡恣蝞銝綽 敶 = 銝 - 銝
+ */
+ public final static Consumer CALCULATE_GRADIENT_LH_ABS = colors -> {
+ if (colors.length <= 2) return;
+ Color[] back = colors[0], next = colors[2];
+ for (int i = 1, maxI = colors.length - 2; i < maxI; ) {
+ Color[] now1 = colors[i].clone();
+ Color[] now2 = next;
+ for (int index = 0; index < now2.length; index++) {
+ now2[index] = COLOR_DIFF_ABS.function(next[index], back[index]);
+ }
+ back = now1;
+ next = colors[++i];
+ }
+ };
+
+ /**
+ * 拚萄椰喳頧祆雿嚗嗅唳臬舫嚗憒冽唾隡堆霂瑟批銝孵隡
+ * key = "isCopy" value = boolean 啣 隞銵典頧祆雿臬阡閬瑁箸啁拚蛛憒銝閬典拚萎葉餈銵頧研
+ */
+ public final static ProTransForm REVERSE_LR = (colorMatrix, value) -> {
+ if (value != null) {
+ Cell> isCopy = value.get("isCopy");
+ if (isCopy != null) {
+ return colorMatrix.reverseLR(Boolean.parseBoolean(isCopy.toString()));
+ }
+ }
+ return colorMatrix.reverseLR(true);
+ };
+
+ /**
+ * 拚萄椰喳頧祆雿嚗嗅唳臬舫嚗憒冽唾隡堆霂瑟批銝孵隡
+ * key = "isCopy" value = boolean 啣
+ */
+ public final static ProTransForm REVERSE_BT = (colorMatrix, value) -> {
+ if (value != null) {
+ Cell> isCopy = value.get("isCopy");
+ if (isCopy != null) {
+ return colorMatrix.reverseBT(Boolean.parseBoolean(isCopy.toString()));
+ }
+ }
+ return colorMatrix.reverseBT(true);
+ };
+
+ /**
+ * 拚菜批椰喟孵餈銵隡豢雿嚗雿踹曉摰踝閬隡 times
+ */
+ public final static ProTransForm SLIT_LR = (colorMatrix, value) -> {
+ if (value == null || !value.containsKey("times")) {
+ throw new OperatorOperationException("拚菜隡豢雿閬其蝵桅★ times 嗡誨銵冽銝銝芸蝝典拚萎葉璅芸隡詨啜");
+ }
+ // 瑕唳赤隡詨
+ int times = value.get("times").getIntValue();
+ // 撘憪隡
+ Color[][] res = new Color[colorMatrix.getRowCount()][colorMatrix.getColCount() * times];
+ int index = -1;
+ for (Color[] colors : colorMatrix.toArrays()) {
+ Color[] re = res[++index];
+ int x1 = 0, x2 = times;
+ for (Color color : colors) {
+ // 刻隡訾銝芸蝝銝箏亦 times 摰
+ for (int x = x1; x < x2; x++) {
+ re[x] = color;
+ }
+ x1 += times;
+ x2 += times;
+ }
+ }
+ return ColorMatrix.parse(res);
+ };
+
+ /**
+ * 拚菜找銝孵餈銵隡豢雿嚗雿踹曉摰踝閬隡 times
+ */
+ public final static ProTransForm SLIT_BT = (colorMatrix, value) -> {
+ if (value == null || !value.containsKey("times")) {
+ throw new OperatorOperationException("拚菜隡豢雿閬其蝵桅★ times 嗡誨銵冽銝銝芸蝝典拚萎葉璅芸隡詨啜");
+ }
+ // 瑕唳赤隡詨
+ int times = value.get("times").getIntValue();
+ // 撘憪隡
+ Color[][] res = new Color[colorMatrix.getRowCount() * times][colorMatrix.getColCount()];
+ int x1 = 0, x2 = times;
+ for (Color[] colors : colorMatrix.toArrays()) {
+ // 刻撠銵隡 times
+ for (int i = x1; i < x2; i++) {
+ res[i] = colors.clone();
+ }
+ x1 += times;
+ x2 += times;
+ }
+ return ColorMatrix.parse(res);
+ };
+
private boolean isGrayscale;
/**
@@ -169,17 +389,7 @@ public static ColorMatrix parse(String inputString) {
*/
public static ColorMatrix parseGrayscale(String inputString) {
Color[][] colors = ASIO.parseImageGetColorArray(inputString);
- return GrayscaleColors(colors);
- }
-
- /**
- * 撠曉URL閫嚗撟嗉瑕撖孵曉拚
- *
- * @param url 閬鋡怨圾URL撖寡情
- * @return URL撖寡情撖孵曉拚萸
- */
- public static ColorMatrix parseGrayscale(URL url) {
- return GrayscaleColors(ASIO.parseURLGetColorArray(url));
+ return ColorMatrix.GrayscaleColors(colors);
}
/**
@@ -266,6 +476,51 @@ public static ColorMatrix parse(URL url) {
return ColorMatrix.parse(ASIO.parseURLGetColorArray(url));
}
+
+ /**
+ * 撠曉URL閫嚗撟嗉瑕撖孵曉拚
+ *
+ * @param url 閬鋡怨圾URL撖寡情
+ * @return URL撖寡情撖孵曉拚萸
+ */
+ public static ColorMatrix parseGrayscale(URL url) {
+ return ColorMatrix.GrayscaleColors(ASIO.parseURLGetColorArray(url));
+ }
+
+ /**
+ * 雿輻函隞嗅銝銝芸曉唳格嚗撟嗉瑕撖孵曉拚萸
+ *
+ * @param inputComponent 賢鋡急箏曉拚萇唳桃隞嗚
+ * @return 隞蝏隞嗡葉箸亦曉拚萄笆鞊∼
+ */
+ public static ColorMatrix parse(InputComponent inputComponent) {
+ return parse(inputComponent, true);
+ }
+
+ /**
+ * 雿輻函隞嗅銝銝芸曉唳格嚗撟嗉瑕撖孵曉拚萸
+ *
+ * @param inputComponent 賢鋡急箏曉拚萇唳桃隞嗚
+ * @param isOC 憒霈曄蔭銝 true 隞銵冽唳株亥挽憭撖寡情撘銝喲凋漱望嗥恣嚗典撠銝閬撖寧隞嗉銵撘喲剜雿嚗銋隞銵冽嗅芯蝙函隞塚雿銝隡撘銝喲剔隞嗅笆鞊∼
+ *
+ * If set to true, it means that the opening and closing of data input device objects are managed by the framework, and there will be no need to open or close components externally. Conversely, it means that the framework only uses components, but will not open or close component objects.
+ * @return 隞蝏隞嗡葉箸亦曉拚萄笆鞊∼
+ */
+ public static ColorMatrix parse(InputComponent inputComponent, boolean isOC) {
+ boolean isOk;
+ if (!inputComponent.isOpen() && isOC) {
+ isOk = inputComponent.open();
+ } else {
+ isOk = true;
+ }
+ if (isOk) {
+ // 撘憪餈銵唳格
+ ColorMatrix parse = ColorMatrix.parse(ASIO.parseImageGetColorArray(inputComponent.getBufferedImage()));
+ if (isOC) ASIO.close(inputComponent);
+ return parse;
+ } else throw new OperatorOperationException("Unable to open your inputComponent.");
+ }
+
/**
* 撠銝銝芸曉拚萎葉蝝頧祆X銝箔脣潘瑕啁啣漲拚萸
*
@@ -283,6 +538,58 @@ private static ColorMatrix GrayscaleColors(Color[][] colors) {
return new ColorMatrix(colors.length, colors[0].length, colors, true);
}
+ /**
+ * 瑕唳祆唳株粹餉摰啣笆鞊
+ *
+ * @param colorMatrix 閬鋡怨箇曉拙耦
+ * @param sep 颲箸園閬雿輻函蝚
+ * @return 銝銝芯其撠曉銝剔憸脫啣潭低SV澆颲箏唳摰隞嗡葉摰圈餉
+ */
+ public static Consumer getSAVE_TEXT(ColorMatrix colorMatrix, char sep) {
+ return (stream) -> {
+ try {
+ int rowCount = 0;
+ for (Color[] colors : colorMatrix.toArrays()) {
+ stream.write(String.valueOf(++rowCount));
+ for (Color color : colors) {
+ stream.write(sep);
+ stream.write(String.valueOf(color.getRGB()));
+ }
+ stream.newLine();
+ }
+ } catch (IOException e) {
+ throw new OperatorOperationException("Write data exception!", e);
+ }
+ };
+ }
+
+ /**
+ * 撠曉隞丕SCII敶W颲箏唳摰隞嗡葉
+ *
+ * @param colorMatrix 閬鋡怨箇曉撖寡情
+ * @param Mode 閬鋡怨箇憸脤
+ * @param colorBoundary 颲箸嗥憸脰器啣
+ * @param imageAscii1 颲箸嗥ASCII
+ * @param imageAscii2 颲箸嗥ASCII
+ * @return 銝銝服SCII蝚血瑞砍曉
+ */
+ public static Consumer getSAVE_ASCII(ColorMatrix colorMatrix, byte Mode, int colorBoundary, char imageAscii1, char imageAscii2) {
+ return bufferedWriter -> {
+ try {
+ for (Color[] colors : colorMatrix.toArrays()) {
+ for (Color color : colors) {
+ if (((color.getRGB() >> Mode) & 0xFF) > colorBoundary) {
+ bufferedWriter.write(imageAscii1);
+ } else bufferedWriter.write(imageAscii2);
+ }
+ bufferedWriter.newLine();
+ }
+ } catch (IOException e) {
+ throw new OperatorOperationException("Write data exception!", e);
+ }
+ };
+ }
+
/**
* 撠銝支葵雿啗銵瘙寞嚗瑚冽霂瑕API霂湔
*
@@ -309,7 +616,7 @@ public ColorMatrix add(ColorMatrix value) {
*/
@Override
public ColorMatrix diff(ColorMatrix value) {
- throw new UnsupportedOperationException("The color matrix object does not support the operation of \"addition\", \"subtraction\" and \"multiplication\", because the calculation of such operations on the color object is not necessary!");
+ return agg(value, COLOR_DIFF_REMAINDER);
}
/**
@@ -348,6 +655,43 @@ public ColorMatrix agg(ColorMatrix value, ManyTrans manyTrans) {
}
}
+ /**
+ * 函拚萄典霈∠嚗雿踹拚萄臭誑皛∟雲隞祉瘙銝霈∠雿
+ *
+ * Computing occurs within the matrix, enabling the matrix to meet our needs and computational operations.
+ *
+ * @param action 霈∠摰圈餉嚗舀芸銋銋舀湔乩蝙典蝵桀啜
+ *
+ * Computational implementation logic supports customization and direct use of built-in implementations.
+ * @param isCopy 霈∠雿臬西冽瑁銋啁銝剜扯嚗憒霈曄蔭銝 true 隞銵刻恣蝞雿撠鈭唳唳桐葉嚗銝隡敶勗拚萄笆鞊∼
+ *
+ * Whether the calculation operation should be performed in the copied array. If set to true, it means that the calculation operation will occur in the new data and will not affect the original matrix object.
+ * @return 霈∠銋拚萄笆鞊∼
+ *
+ * The calculated matrix object.
+ */
+ public ColorMatrix calculate(Consumer action, boolean isCopy) {
+ if (isCopy) {
+ Color[][] colors = this.copyToNewArrays();
+ action.accept(colors);
+ return ColorMatrix.parse(colors);
+ } else {
+ action.accept(this.toArrays());
+ return this;
+ }
+ }
+
+ /**
+ * 拚萄X雿賣堆冽迨賣唬葉典臭誑隡憭銝芰拚萄X芋撘嚗摰啣蝘銝拚菔蓮X嚗嗉臭誑芸銋拚萄X園閬雿輻函餉
+ *
+ * @param transformation 拚萄a餉
+ * @param value 拚萎葉X雿霈∠園閬嗅啣笆鞊∼
+ * @return 拚萄V餈啁拚萄笆鞊∼
+ */
+ public ColorMatrix converter(ProTransForm transformation, HashMap> value) {
+ return transformation.function(this, value);
+ }
+
/**
* 瑕啁拚萎葉摰寧啣
*
@@ -516,7 +860,7 @@ public ColorMatrix shuffle(long seed) {
public Color[][] copyToNewArrays() {
Color[][] colors = this.toArrays();
Color[][] res = new Color[colors.length][colors[0].length];
- System.arraycopy(colors, 0, res, 0, colors.length);
+ ASClass.array2DCopy(colors, res);
return res;
}
@@ -988,7 +1332,7 @@ public final void contrast(int contrastThreshold) {
public ColorMatrix extractImage(int x1, int y1, int x2, int y2) {
if (x1 >= x2 || y1 >= y2) {
throw new OperatorOperationException("曉霂荔刻挽蝵桃寞霂!!!\nAn error occurred in image extraction. The extraction coordinate point you set is incorrect!!!\n" +
- "ERROR => (" + x1 + ',' + y1 + ") >= (" + y1 + ',' + y2 + ')');
+ "ERROR => (" + x1 + ',' + y1 + ") >= (" + x2 + ',' + y2 + ')');
}
if (x2 >= this.getColCount() || y2 >= this.getRowCount()) {
throw new OperatorOperationException("曉霂荔其賣銝摮其曉銝剔鈾nAn error occurred in image extraction. You cannot extract coordinate points that do not exist in the image\n" +
@@ -1162,6 +1506,40 @@ public double avg(byte colorMode) {
return sum / (double) (this.getNumberOfDimensions());
}
+ /**
+ * 霈∠箄蔭撱Y妖憭批嚗隞亙蝝銝箏雿
+ *
+ * Calculate the size of the area within the contour, in pixels.
+ *
+ * @param contourColor 頧桀蝥輻憸脣笆鞊∴憒蝝憸脫啣潔甇文潔湛霈支蛹嗅鈭颲寞
+ *
+ * The color object of the outline. If the color value of a pixel matches this value, it is considered to belong to the border.
+ * @return 頧桀蝝圈
+ *
+ * The number of all pixels within the contour.
+ */
+ public int contourArea(Color contourColor) {
+ int rgb = contourColor.getRGB();
+ int res = 0;
+ for (Color[] colors : this.toArrays()) {
+ boolean isOk = false;
+ for (Color color : colors) {
+ if (isOk) {
+ ++res;
+ if (color.getRGB() == rgb) {
+ isOk = false;
+ }
+ continue;
+ }
+ if (color.getRGB() == rgb) {
+ isOk = true;
+ ++res;
+ }
+ }
+ }
+ return res;
+ }
+
/**
* 曉賣堆刻砲賣啁憭銋銝嚗臭誑撖孵曉鈭銝頞喳憸脫啣潸銵雿嚗
*
@@ -1203,7 +1581,7 @@ public ColorMatrix erode(int width, int height, boolean isCopy, Color backColor)
for (Color[] colors : nowSub.toArrays()) {
for (Color color : colors) {
if (color.getRGB() == colorNum) {
- // 唬暺 湔亙霂亙拚萎葉憸脫湔V蛹暺
+ // 唬 湔亙霂亙拚萎葉憸脫湔V蛹
isR = true;
}
}
@@ -1226,6 +1604,223 @@ public ColorMatrix erode(int width, int height, boolean isCopy, Color backColor)
return res;
}
+ /**
+ * 瘚瑁孵瑕唬舅銝芰拚萎銝撌血喳撟嗡鈭抒啁拚萄笆鞊∴閬瘜冽荔霂交雿銝隡暹亦拚蛛港隡湔寡冽寧唳柴
+ *
+ * The shallow copy method obtains a new matrix object generated by merging two matrices up and down or left and right. Note that this operation does not link the matrix, nor does it change the caller's data.
+ *
+ * @param colorMatrix 閬鋡怨蕭憸脩拚萄笆鞊∼
+ *
+ * The color matrix object that needs to be appended.
+ * @param isLR 憒霈曄蔭銝 true 隞銵其蝙典椰唾蕭孵餈銵餈賢嚗 憒霈曄蔭銝 false 隞銵其蝙其銝餈賢孵餈銵餈賢
+ *
+ * If set to true, it means appending using the left and right appending method. If set to false, it means appending using the up and down appending method.
+ * @return 餈賢銋拚萄笆鞊∴霂亦拚萄笆鞊∩葉銵銝拚菜舀唾
+ *
+ * The appended matrix object has no rows associated with the original matrix.
+ */
+ public ColorMatrix append(ColorMatrix colorMatrix, boolean isLR) {
+ if (isLR) {
+ Color[][] colors1 = this.toArrays();
+ Color[][] colors2 = colorMatrix.toArrays();
+ if (colors1.length != colors2.length) {
+ throw new OperatorOperationException("撌血唾蕭拚萄笆鞊⊿閬靽銵啁詨嚗");
+ }
+ Color[][] res = new Color[colors1.length][this.getColCount() + colorMatrix.getColCount()];
+ int index = -1;
+ for (Color[] re : res) {
+ ASClass.mergeArray(re, colors1[++index], colors2[index]);
+ }
+ return ColorMatrix.parse(res);
+ }
+ Color[][] colors1 = this.copyToNewArrays();
+ Color[][] colors2 = colorMatrix.copyToNewArrays();
+ if (colors1.length != colors2.length) {
+ throw new OperatorOperationException("銝銝餈賢拚萄笆鞊⊿閬靽啁詨嚗");
+ }
+ Color[][] res = new Color[colors1.length + colors2.length][];
+ ASClass.mergeArray(res, colors1, colors2);
+ return ColorMatrix.parse(res);
+ }
+
+ /**
+ * 撠曉拚萎葉摰憸脫湔唳啣潛拚菔瑕啜
+ *
+ * @param colorMode 閬鋡怨瑕圈脤蝻
+ * @return 撖孵憸脤憸脫啣潛憸脩拚萄笆鞊∼
+ */
+ public final IntegerMatrix getChannel(int colorMode) {
+ int[][] res = new int[this.getRowCount()][this.getColCount()];
+ int y = -1;
+ for (Color[] colors : this.toArrays()) {
+ int[] re = res[++y];
+ int x = -1;
+ for (Color color : colors) {
+ re[++x] = (color.getRGB() >> colorMode) & 0xFF;
+ }
+ }
+ return IntegerMatrix.parse(res);
+ }
+
+ /**
+ * 拚萎葉蝏嗡銝芰拚萸
+ *
+ * @param start 拚萇撌虫閫撖寡情
+ * @param end 拚萇喃閫撖寡情
+ * @param color 蝏嗥頧桀憸脣笆鞊∼
+ */
+ public void drawRectangle(IntegerCoordinateTwo start, IntegerCoordinateTwo end, Color color) {
+ Color[][] colors = this.toArrays();
+ int x1 = start.getX();
+ int x2 = end.getX();
+ int y1 = start.getY();
+ int y2 = end.getY();
+ // 擐撠韏瑕蝏甇Y寧 x 頧游港蛹 color 憸莎雿輻肘頧渲瑕嚗
+ Color[] color1 = colors[start.getY()];
+ Color[] color2 = colors[end.getY()];
+ for (int i = x1; i <= x2; i++) {
+ color1[i] = color;
+ color2[i] = color;
+ }
+ // 嗅撠拐寧 y 頧游銝 color 憸莎雿輻肝頧渲瑕嚗
+ for (int i = y1; i <= y2; i++) {
+ Color[] colorRow = colors[i];
+ colorRow[x1] = color;
+ colorRow[x2] = color;
+ }
+ }
+
+ /**
+ * 撠曉餈銵璅⊥踹寥霈∠
+ *
+ * @param distanceAlgorithm 閬雿輻函摨阡霈∠蝏隞嗚
+ *
+ * The metric calculation component that needs to be used.
+ * @param template 刻銵璅⊥踹寥嗥鋡怠寥璅⊥踴
+ *
+ * The template to be matched during template matching.
+ * @param channel 刻銵霈∠塚閬鋡怨恣蝞憸脤
+ *
+ * When calculating, the color channel to be calculated is required.
+ * @param sep 曉瑞妖甇仿踵啣潦霂交啣澆嚗隡憓撘箄恣蝞摨虫扯踝霂交啣潛撠嚗隡憓撘箄恣蝞蝎曄&摨艾
+ *
+ * Image convolution step size value. An increase in this value will enhance the speed and performance of the calculation, while a decrease in this value will enhance the accuracy of the calculation.
+ * @param isMAX 憒霈曄蔭銝 true 隞銵典訾撮摨衣頂唳憭抒摮曉雿銝箝
+ *
+ * If set to true, the coordinate of the sub image with the largest similarity coefficient is taken as the coordinate.
+ * @return 蝏餈霈∠銋嚗銝敶拚萄笆鞊⊥訾撮摮曉撌虫閫啣澆笆鞊∼
+ */
+ public final Map.Entry templateMatching(DistanceAlgorithm distanceAlgorithm, ColorMatrix template, int channel, int sep, boolean isMAX) {
+ // 撘憪寥
+ IntegerMatrix channel1 = template.getChannel(channel);
+ IntegerMatrix channel2 = this.getChannel(channel);
+ // 擐箇拚1銝剔詨憭批摮拚萄曉
+ int rowCount1 = this.getRowCount();
+ int colCount1 = this.getColCount();
+ int rowCount2 = template.getRowCount();
+ int colCount2 = template.getColCount();
+ if (rowCount1 < rowCount2 || colCount1 < colCount2) {
+ throw new OperatorOperationException("函璅⊥輻拚萄偕撖貉憭!!");
+ }
+ int[] xy = new int[2];
+ double value = isMAX ? Integer.MIN_VALUE : Integer.MAX_VALUE;
+
+ if (rowCount1 == rowCount2) {
+ // 餈蝘萎誨銵典臭誑雿輻其寞
+ int ye = rowCount2 - 1;
+ for (int y = 0; y < rowCount1; y += sep, ye += sep) {
+ double trueDistance = distanceAlgorithm.getTrueDistance(channel2.extractSrcMat(y, ye), channel1);
+ if (isMAX) {
+ if (value < trueDistance) {
+ value = trueDistance;
+ xy[1] = y;
+ }
+ } else {
+ if (value > trueDistance) {
+ value = trueDistance;
+ xy[1] = y;
+ }
+ }
+ }
+ return new AbstractMap.SimpleEntry<>(value, new IntegerCoordinateTwo(xy[0], xy[1]));
+ }
+ int ye = rowCount2 - 1;
+ for (int y = 0; ye < rowCount1; y += sep, ye += sep) {
+ int xe = colCount2 - 1;
+ for (int x = 0; xe < colCount1; x += sep, xe += sep) {
+ // 霈∠箇訾撮摨
+ double trueDistance = distanceAlgorithm.getTrueDistance(channel2.extractMat(x, y, xe, ye), channel1);
+ if (isMAX) {
+ if (value < trueDistance) {
+ value = trueDistance;
+ xy[0] = x;
+ xy[1] = y;
+ }
+ } else {
+ if (value > trueDistance) {
+ value = trueDistance;
+ xy[0] = x;
+ xy[1] = y;
+ }
+ }
+ }
+ }
+ return new AbstractMap.SimpleEntry<>(value, new IntegerCoordinateTwo(xy[0], xy[1]));
+ }
+
+ /**
+ * @param distanceAlgorithm 閬雿輻函摨阡霈∠蝏隞嗚
+ *
+ * The metric calculation component that needs to be used.
+ * @param template 刻銵璅⊥踹寥嗥鋡怠寥璅⊥踴
+ *
+ * The template to be matched during template matching.
+ * @param channel 刻銵霈∠塚閬鋡怨恣蝞憸脤
+ *
+ * When calculating, the color channel to be calculated is required.
+ * @param sep 曉瑞妖甇仿踵啣潦霂交啣澆嚗隡憓撘箄恣蝞摨虫扯踝霂交啣潛撠嚗隡憓撘箄恣蝞蝎曄&摨艾
+ *
+ * Image convolution step size value. An increase in this value will enhance the speed and performance of the calculation, while a decrease in this value will enhance the accuracy of the calculation.
+ * @param cFilter 訾撮蝟餅啗皛日餉摰堆刻典臭誑芸銋銋血訾撮摨衣頂啁餈皛斗雿嚗蝚血蝟餅啣笆摨靽⊥臬隡鋡急溶啁唳桐葉
+ * @return 曉銝剜蝚血餈皛斗∩辣摮拚萎縑舀唳桀笆鞊∼
+ *
+ * All sub matrix information data objects in the image that meet the filtering conditions.
+ */
+ public final ArrayList> templateMatching(DistanceAlgorithm distanceAlgorithm, ColorMatrix template, int channel, int sep, DoubleFiltering cFilter) {
+ // 撘憪寥
+ IntegerMatrix channel1 = template.getChannel(channel);
+ IntegerMatrix channel2 = this.getChannel(channel);
+ // 擐箇拚1銝剔詨憭批摮拚萄曉
+ int rowCount1 = this.getRowCount(), colCount1 = this.getColCount();
+ int rowCount2 = template.getRowCount(), colCount2 = template.getColCount();
+ if (rowCount1 < rowCount2 || colCount1 < colCount2) {
+ throw new OperatorOperationException("函璅⊥輻拚萄偕撖貉憭!!");
+ }
+ ArrayList> res = new ArrayList<>();
+ if (rowCount1 == rowCount2) {
+ // 餈蝘萎誨銵典臭誑雿輻其寞
+ int ye = rowCount2 - 1;
+ for (int y = 0; y < rowCount1; y += sep, ye += sep) {
+ double trueDistance = distanceAlgorithm.getTrueDistance(channel2.extractSrcMat(y, ye), channel1);
+ if (cFilter.isComplianceEvents(trueDistance))
+ res.add(new AbstractMap.SimpleEntry<>(trueDistance, new IntegerCoordinateTwo(0, y)));
+ }
+ return res;
+ }
+ // 餈撠曹誨銵其賢雿輻其寞
+ int ye = rowCount2 - 1;
+ for (int y = 0; ye < rowCount1; y += sep, ye += sep) {
+ int xe = colCount2 - 1;
+ for (int x = 0; xe < colCount1; x += sep, xe += sep) {
+ // 霈∠箇訾撮摨
+ double trueDistance = distanceAlgorithm.getTrueDistance(channel2.extractMat(x, y, xe, ye), channel1);
+ if (cFilter.isComplianceEvents(trueDistance))
+ res.add(new AbstractMap.SimpleEntry<>(trueDistance, new IntegerCoordinateTwo(x, y)));
+ }
+ }
+ return res;
+ }
+
/**
* 撠曉拚萄蝷箏箸伐雿踹函拚萇曉唳株賢鋡怠蝷箏箸乓
*
@@ -1282,21 +1877,26 @@ public void save(String path, char sep) {
*/
@Override
public void save(File path, char sep) {
- ASIO.writer(path, (stream) -> {
- try {
- int rowCount = 0;
- for (Color[] colors : this.toArrays()) {
- stream.write(String.valueOf(++rowCount));
- for (Color color : colors) {
- stream.write(sep);
- stream.write(String.valueOf(color.getRGB()));
- }
- stream.newLine();
- }
- } catch (IOException e) {
- throw new OperatorOperationException("Write data exception!", e);
- }
- });
+ ASIO.writer(path, getSAVE_TEXT(this, sep));
+ }
+
+ /**
+ * 撠撖寡情鈭斤梁洵銝寞唳株箇隞嗉銵唳桃颲箝
+ *
+ * Submit the object to a third-party data output component for data output.
+ *
+ * @param outputComponent 蝚砌寞唳株箄挽憭撖寡情摰啜
+ *
+ * Implementation of third-party data output device objects.
+ */
+ @Override
+ public void save(OutputComponent outputComponent) {
+ if (!outputComponent.isOpen()) {
+ if (!outputComponent.open())
+ throw new OperatorOperationException("函唳株箇隞嗆撘憭梯揖\nYour data output component failed to open.");
+ }
+ outputComponent.writeImage(this);
+ ASIO.close(outputComponent);
}
/**
@@ -1319,20 +1919,7 @@ public void save(File path, char sep) {
* ASCII Symbol In the output ASCII image file, the ASCII value corresponding to the constituent characters of the image for coordinates that are less than the threshold value.
*/
public void save(File path, byte Mode, int colorBoundary, char imageAscii1, char imageAscii2) {
- ASIO.writer(path, bufferedWriter -> {
- try {
- for (Color[] colors : this.toArrays()) {
- for (Color color : colors) {
- if (((color.getRGB() >> Mode) & 0xFF) > colorBoundary) {
- bufferedWriter.write(imageAscii1);
- } else bufferedWriter.write(imageAscii2);
- }
- bufferedWriter.newLine();
- }
- } catch (IOException e) {
- throw new OperatorOperationException("Write data exception!", e);
- }
- });
+ ASIO.writer(path, getSAVE_ASCII(this, Mode, colorBoundary, imageAscii1, imageAscii2));
}
/**
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColumnDoubleMatrix.java b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColumnDoubleMatrix.java
index 285c828..6e11a16 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColumnDoubleMatrix.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColumnDoubleMatrix.java
@@ -2,6 +2,7 @@
import zhao.algorithmMagic.core.ASDynamicLibrary;
import zhao.algorithmMagic.exception.OperatorOperationException;
+import zhao.algorithmMagic.io.OutputComponent;
import zhao.algorithmMagic.operands.RCNOperands;
import zhao.algorithmMagic.operands.vector.DoubleVector;
import zhao.algorithmMagic.utils.ASClass;
@@ -677,4 +678,23 @@ public void save(File path, char sep) {
}
});
}
+
+ /**
+ * 撠撖寡情鈭斤梁洵銝寞唳株箇隞嗉銵唳桃颲箝
+ *
+ * Submit the object to a third-party data output component for data output.
+ *
+ * @param outputComponent 蝚砌寞唳株箄挽憭撖寡情摰啜
+ *
+ * Implementation of third-party data output device objects.
+ */
+ @Override
+ public void save(OutputComponent outputComponent) {
+ if (!outputComponent.isOpen()) {
+ if (!outputComponent.open())
+ throw new OperatorOperationException("函唳株箇隞嗆撘憭梯揖\nYour data output component failed to open.");
+ }
+ outputComponent.writeMat(this);
+ ASIO.close(outputComponent);
+ }
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColumnIntegerMatrix.java b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColumnIntegerMatrix.java
index 7549490..b863083 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColumnIntegerMatrix.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/ColumnIntegerMatrix.java
@@ -2,6 +2,7 @@
import zhao.algorithmMagic.core.ASDynamicLibrary;
import zhao.algorithmMagic.exception.OperatorOperationException;
+import zhao.algorithmMagic.io.OutputComponent;
import zhao.algorithmMagic.operands.RCNOperands;
import zhao.algorithmMagic.operands.vector.IntegerVector;
import zhao.algorithmMagic.utils.ASClass;
@@ -672,4 +673,23 @@ public void save(File path, char sep) {
}
});
}
+
+ /**
+ * 撠撖寡情鈭斤梁洵銝寞唳株箇隞嗉銵唳桃颲箝
+ *
+ * Submit the object to a third-party data output component for data output.
+ *
+ * @param outputComponent 蝚砌寞唳株箄挽憭撖寡情摰啜
+ *
+ * Implementation of third-party data output device objects.
+ */
+ @Override
+ public void save(OutputComponent outputComponent) {
+ if (!outputComponent.isOpen()) {
+ if (!outputComponent.open())
+ throw new OperatorOperationException("函唳株箇隞嗆撘憭梯揖\nYour data output component failed to open.");
+ }
+ outputComponent.writeMat(this);
+ ASIO.close(outputComponent);
+ }
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/DoubleMatrix.java b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/DoubleMatrix.java
index ab7e6df..b997219 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/DoubleMatrix.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/DoubleMatrix.java
@@ -185,6 +185,15 @@ public static DoubleMatrix parse(DataFrame dataFrame, int height, int width) {
return parse(doubles);
}
+ public static DoubleMatrix parse(IntegerMatrix parse1) {
+ double[][] doubles = new double[parse1.getRowCount()][];
+ int index = -1;
+ for (int[] ints : parse1.toArrays()) {
+ doubles[++index] = ASClass.IntArray_To_DoubleArray(ints);
+ }
+ return new DoubleMatrix(doubles.length, parse1.getColCount(), doubles);
+ }
+
/**
* 瑕啁拚萎葉摰寧啣
*
@@ -315,15 +324,11 @@ public DoubleMatrix diff(DoubleMatrix value) {
@Override
public Double moduleLength() {
double res = 0;
- int rowPointer = this.RowPointer;
- PointerReset();
- while (this.MovePointerDown()) {
- double[] doubles1 = this.toArray();
- for (double v : doubles1) {
- res += ASMath.Power2(v);
+ for (double[] ints : this.toArrays()) {
+ for (double anInt : ints) {
+ res += anInt * anInt;
}
}
- this.RowPointer = rowPointer;
return res;
}
@@ -632,6 +637,32 @@ public DoubleMatrix extractMat(int x1, int y1, int x2, int y2) {
return DoubleMatrix.parse(colors);
}
+ /**
+ * 箏拚萄笆鞊
+ *
+ * @param y1 鋡急拚萄典拚萎葉韏瑕嫘
+ *
+ * The starting coordinate point of the extracted matrix in the original matrix.
+ * @param y2 鋡急拚萄典拚萎葉蝏甇W嫘
+ *
+ * The end coordinate point of the extracted matrix in the original matrix.
+ * @return 游耦拚萄笆鞊∩葉摮拚萄笆鞊∼
+ */
+ @Override
+ public DoubleMatrix extractSrcMat(int y1, int y2) {
+ if (y1 >= y2) {
+ throw new OperatorOperationException("游耦拚菜霂荔刻挽蝵桃寞霂!!!\nAn error occurred in mat extraction. The extraction coordinate point you set is incorrect!!!\n" +
+ "ERROR => (" + y1 + ") >= (" + y2 + ')');
+ }
+ double[][] res_colors = new double[y2 - y1][];
+ double[][] colors1 = this.toArrays();
+ int index = -1;
+ for (int i = y1; i < y2; i++) {
+ res_colors[++index] = colors1[i];
+ }
+ return DoubleMatrix.parse(res_colors);
+ }
+
@Override
protected void reFresh() {
this.PointerReset();
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/IntegerMatrix.java b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/IntegerMatrix.java
index f3eb817..633108a 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/IntegerMatrix.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/IntegerMatrix.java
@@ -338,15 +338,11 @@ protected void reFresh() {
@Override
public Integer moduleLength() {
int res = 0;
- int rowPointer = this.RowPointer;
- PointerReset();
- while (this.MovePointerDown()) {
- int[] ints = toArray();
- for (int v : ints) {
- res += ASMath.Power2(v);
+ for (int[] ints : this.toArrays()) {
+ for (int anInt : ints) {
+ res += anInt * anInt;
}
}
- this.RowPointer = rowPointer;
return res;
}
@@ -629,7 +625,7 @@ public IntegerMatrix deleteRelatedDimensions(int index, double thresholdLeft, do
public IntegerMatrix extractMat(int x1, int y1, int x2, int y2) {
if (x1 >= x2 || y1 >= y2) {
throw new OperatorOperationException("游耦拚菜霂荔刻挽蝵桃寞霂!!!\nAn error occurred in mat extraction. The extraction coordinate point you set is incorrect!!!\n" +
- "ERROR => (" + x1 + ',' + x2 + ") >= (" + x2 + ',' + y2 + ')');
+ "ERROR => (" + x1 + ',' + y1 + ") >= (" + x2 + ',' + y2 + ')');
}
if (x2 >= this.getColCount() || y2 >= this.getRowCount()) {
throw new OperatorOperationException("游耦拚菜霂荔其賣銝摮其拚萎葉鈾nAn error occurred in mat extraction. You cannot extract coordinate points that do not exist in the image\n" +
@@ -644,6 +640,32 @@ public IntegerMatrix extractMat(int x1, int y1, int x2, int y2) {
return IntegerMatrix.parse(colors);
}
+ /**
+ * 箏拚萄笆鞊
+ *
+ * @param y1 鋡急拚萄典拚萎葉韏瑕嫘
+ *
+ * The starting coordinate point of the extracted matrix in the original matrix.
+ * @param y2 鋡急拚萄典拚萎葉蝏甇W嫘
+ *
+ * The end coordinate point of the extracted matrix in the original matrix.
+ * @return 游耦拚萄笆鞊∩葉摮拚萄笆鞊∼
+ */
+ @Override
+ public IntegerMatrix extractSrcMat(int y1, int y2) {
+ if (y1 >= y2) {
+ throw new OperatorOperationException("游耦拚菜霂荔刻挽蝵桃寞霂!!!\nAn error occurred in mat extraction. The extraction coordinate point you set is incorrect!!!\n" +
+ "ERROR => (" + y1 + ") >= (" + y2 + ')');
+ }
+ int[][] res_colors = new int[y2 - y1][];
+ int[][] colors1 = this.toArrays();
+ int index = -1;
+ for (int i = y1; i < y2; i++) {
+ res_colors[++index] = colors1[i];
+ }
+ return IntegerMatrix.parse(res_colors);
+ }
+
/**
* 撠唳格蝏湔斤啁撌衣宏n銝芯蝵殷撟嗉瑕啁啣
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/NumberMatrix.java b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/NumberMatrix.java
index 1c079ef..5ebd82e 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/NumberMatrix.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/NumberMatrix.java
@@ -78,4 +78,17 @@ protected NumberMatrix(int rowCount, int colCount, ArraysType arraysType) {
* @return 游耦拚萄笆鞊∩葉摮拚萄笆鞊∼
*/
public abstract ImplementationType extractMat(int x1, int y1, int x2, int y2);
+
+ /**
+ * 箏拚萄笆鞊
+ *
+ * @param y1 鋡急拚萄典拚萎葉韏瑕嫘
+ *
+ * The starting coordinate point of the extracted matrix in the original matrix.
+ * @param y2 鋡急拚萄典拚萎葉蝏甇W嫘
+ *
+ * The end coordinate point of the extracted matrix in the original matrix.
+ * @return 游耦拚萄笆鞊∩葉摮拚萄笆鞊∼
+ */
+ public abstract ImplementationType extractSrcMat(int y1, int y2);
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/RectangleMatrix.java b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/RectangleMatrix.java
new file mode 100644
index 0000000..b7a4b54
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/RectangleMatrix.java
@@ -0,0 +1,148 @@
+package zhao.algorithmMagic.operands.matrix;
+
+import java.awt.*;
+import java.util.Arrays;
+
+/**
+ * 曉颲寧拚萄笆鞊∴霂亙笆鞊∩其撖孵曉颲寧撖寡情餈銵銝鈭寞雿嚗刻典臭誑湔交扯嗡葉颲寧霈∠賣堆游末典曉颲寧霈∠銝剜靘臬末
+ *
+ * Image edge matrix object, which is specially used to carry out some special operations on image edge objects. Here you can directly execute the edge computing function to better provide good results in image edge computing.
+ *
+ * @author 韏萄摰
+ * 2023/3/30 16:53
+ */
+public class RectangleMatrix extends ColorMatrix {
+
+ private final int outlineWidthL;
+ private final int outlineHeightR;
+ private final int outlineWidthR;
+ private final int outlineHeightL;
+
+ /**
+ * 銝銝芣摰銵唳桃拚萄笆鞊∴嗡葉銵憭批澆隡暺霈支蝙刻圈
+ *
+ * Construct a matrix object with specified row and column data. The maximum value of row pointer will use the number of rows by default.
+ *
+ * @param rowCount 拚萎葉銵圈
+ *
+ * the number of rows in the matrix
+ * @param colCount 拚萎葉圈
+ *
+ * the number of cols in the matrix
+ * @param colors 霂亦拚萄笆鞊∩葉鈭蝏湔啁撖寡情
+ * @param isGrayscale 憒霈曄蔭銝演rue 隞銵冽迨曉舐啣漲曉
+ * @param outlineWidthL 拙耦韏瑕摰賢漲蝝W
+ * @param outlineWidthR 拙耦蝏甇W捐摨衣揣撘
+ * @param outlineHeightL 拙耦韏瑕擃摨衣揣撘
+ * @param outlineHeightR 拙耦蝏甇a摨衣揣撘
+ */
+ protected RectangleMatrix(int rowCount, int colCount, Color[][] colors, boolean isGrayscale, int outlineWidthL, int outlineHeightR, int outlineWidthR, int outlineHeightL) {
+ super(rowCount, colCount, colors, isGrayscale);
+ this.outlineWidthL = outlineWidthL;
+ this.outlineHeightR = outlineHeightR;
+ this.outlineWidthR = outlineWidthR;
+ this.outlineHeightL = outlineHeightL;
+ }
+
+ /**
+ * 撠銝銝芸曉拚萎葉頧桀撖寡情瑕
+ *
+ * @param colorMatrix 閬鋡急曉拚萄笆鞊
+ * @param rectColor 拚萄笆鞊∠頧桀憸脣笆鞊
+ * @return 憭曉頧桀撖寡情
+ */
+ public static RectangleMatrix parse(ColorMatrix colorMatrix, Color rectColor) {
+ // 撠頧桀擃摨虫摰賢漲霈∠箸
+ int outlineWidthL = colorMatrix.getColCount() - 1;
+ int outlineHeightL = colorMatrix.getRowCount() - 1;
+ int outlineHeightR = 0;
+ int outlineWidthR = 0;
+ // 瑕啗絲憪銝蝏甇Y揣撘
+ boolean isH = false;
+ boolean isW = false;
+ int rc = -1;
+ for (Color[] colors : colorMatrix.toArrays()) {
+ ++rc;
+ boolean isRw = false;
+ int cc = -1;
+ boolean isOk = false;
+ for (Color color : colors) {
+ ++cc;
+ // 斗剖捐
+ if (color.getRGB() != 0xff000000) {
+ isOk = true;
+ if (!isRw && cc < outlineWidthL) {
+ outlineWidthL = cc;
+ outlineWidthR = cc;
+ isW = true;
+ isRw = true;
+ }
+ if (isW) {
+ if (cc > outlineWidthR) outlineWidthR = cc;
+ }
+ }
+ }
+ // 斗剝
+ if (isOk) {
+ if (isH) {
+ if (rc > outlineHeightR) outlineHeightR = rc;
+ } else if (rc < outlineHeightL) {
+ outlineHeightL = rc;
+ outlineHeightR = rc;
+ isH = true;
+ }
+ }
+ }
+ // 批捐擃銝銝芰拚
+ Color[][] colors = new Color[colorMatrix.getRowCount()][colorMatrix.getColCount()];
+ for (Color[] color : colors) {
+ Arrays.fill(color, Color.BLACK);
+ }
+ Color[] row = new Color[colorMatrix.getColCount()];
+ Arrays.fill(row, Color.BLACK);
+ for (int i = outlineWidthL; i <= outlineWidthR; i++) {
+ row[i] = rectColor;
+ }
+ colors[outlineHeightL] = row;
+ colors[outlineHeightR] = row;
+ for (int i = outlineHeightL, colorsLength = outlineHeightR; i <= colorsLength; i++) {
+ Color[] color = colors[i];
+ color[outlineWidthL] = rectColor;
+ color[outlineWidthR] = rectColor;
+ }
+ return new RectangleMatrix(
+ colorMatrix.getRowCount(),
+ colorMatrix.getColCount(),
+ colors,
+ false,
+ outlineWidthL, outlineHeightL,
+ outlineWidthR, outlineHeightR
+ );
+ }
+
+ public int getOutlineWidthL() {
+ return outlineWidthL;
+ }
+
+ public int getOutlineHeightR() {
+ return outlineHeightR;
+ }
+
+ public int getOutlineWidthR() {
+ return outlineWidthR;
+ }
+
+ public int getOutlineHeightL() {
+ return outlineHeightL;
+ }
+
+ @Override
+ public String toString() {
+ return "RectangleMatrix{" +
+ "outlineWidthL=" + getOutlineWidthL() +
+ ", outlineWidthR=" + getOutlineWidthR() +
+ ", outlineHeightL=" + getOutlineHeightL() +
+ ", outlineHeightR=" + getOutlineHeightR() +
+ '}';
+ }
+}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/SaveMatrix.java b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/SaveMatrix.java
index 8de93d2..cf9c386 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/SaveMatrix.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/matrix/SaveMatrix.java
@@ -1,5 +1,7 @@
package zhao.algorithmMagic.operands.matrix;
+import zhao.algorithmMagic.io.OutputComponent;
+
import java.io.File;
/**
@@ -50,4 +52,15 @@ public interface SaveMatrix {
* Separator used when saving.
*/
void save(File path, char sep);
+
+ /**
+ * 撠撖寡情鈭斤梁洵銝寞唳株箇隞嗉銵唳桃颲箝
+ *
+ * Submit the object to a third-party data output component for data output.
+ *
+ * @param outputComponent 蝚砌寞唳株箄挽憭撖寡情摰啜
+ *
+ * Implementation of third-party data output device objects.
+ */
+ void save(OutputComponent outputComponent);
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/table/Cell.java b/src_code/src/main/java/zhao/algorithmMagic/operands/table/Cell.java
index bb6c596..d996085 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/table/Cell.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/table/Cell.java
@@ -3,6 +3,7 @@
import zhao.algorithmMagic.operands.Operands;
import java.io.Serializable;
+import java.util.Date;
/**
* 潭唳桃掩嚗霂交唳桃掩鋡 Multi-type 拚菜雿輻剁撟嗉銵詨笆摨憭銝雿
@@ -33,6 +34,13 @@ public interface Cell extends Serializable, Operands| > {
*/
int getIntValue();
+ /**
+ * @return 敶潔葉摮函湔唳啣潛掩嚗霂交雿餈撠銝臬撖寡情
+ *
+ * The integer numeric type stored in the current cell. This operation will not return the original object.
+ */
+ long getLongValue();
+
/**
* @return 敶潔葉摮函Double啣潛掩嚗霂交雿餈撠銝臬撖寡情
*
@@ -40,6 +48,13 @@ public interface Cell extends Serializable, Operands| > {
*/
double getDoubleValue();
+ /**
+ * @return 敶潔葉摮函 Date 啣潛掩嚗霂交雿餈撠銝臬撖寡情
+ *
+ * The Date numeric type stored in the current cell. This operation will not return the original object.
+ */
+ Date getDate();
+
/**
* @return 敶潔葉摮函摮蝚虫葡啣潛掩嚗霂交雿餈撠銝臬撖寡情
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/table/DataFrame.java b/src_code/src/main/java/zhao/algorithmMagic/operands/table/DataFrame.java
index 8ee0f37..98d8ce4 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/table/DataFrame.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/table/DataFrame.java
@@ -1,8 +1,11 @@
package zhao.algorithmMagic.operands.table;
+import zhao.algorithmMagic.io.OutputComponent;
import zhao.algorithmMagic.operands.Operands;
import zhao.algorithmMagic.utils.transformation.Transformation;
+import java.io.BufferedWriter;
+import java.io.PrintStream;
import java.io.Serializable;
import java.util.List;
@@ -255,6 +258,34 @@ public interface DataFrame extends AggDataFrameData, Iterable, Serializa
*/
DataFrame into_outHtml(String outPath, String tableName);
+ /**
+ * 撠霈∠蝏靘蝏摰唳株箇隞嗉銵唳桃颲箸雿嚗
+ *
+ * @param outputComponent 颲箸唳桅閬雿輻函唳株箇隞
+ * @return 颲箔隡餈唳桅祈澈嚗銝隡蝏甇Z具
+ *
+ * After output, the data set itself will be returned and the call will not be terminated.
+ */
+ DataFrame into_outComponent(OutputComponent outputComponent);
+
+ /**
+ * 暺霈斗孵亦 DF 唳桀笆鞊∩葉唳柴
+ *
+ * The default method is to view data in DF data objects.
+ */
+ void show();
+
+ /**
+ * 摰唳格孵亦 DF 唳桀笆鞊∩葉唳殷霂交雿撠隡雿踹 DF 唳株◤颲箏唳唳格銝准
+ *
+ * Specify the method of viewing data in the DF data object through a data stream, which will cause the DF data to be output into the data stream.
+ *
+ * @param bufferedWriter 閬隡唳桃唳格撖寡情
+ */
+ void show(BufferedWriter bufferedWriter);
+
+ void show(PrintStream printStream);
+
/**
* 撠DF撖寡情銝剔唳株蓮X銝箔銝泓ist摰孵具
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/table/DataFrameBuilder.java b/src_code/src/main/java/zhao/algorithmMagic/operands/table/DataFrameBuilder.java
index c3d4371..043f3a9 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/table/DataFrameBuilder.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/table/DataFrameBuilder.java
@@ -15,6 +15,14 @@ public interface DataFrameBuilder {
*/
Mode getInMode();
+ /**
+ * 霈曄蔭霂餃唳格園閬雿輻函蝚艾刻粉銝銝芣隞嗅笆鞊∠嗅隡
+ *
+ * @param sep 摰唳桀蝚佗霂亙蝚血隡刻粉嗅鋡怨其瑕嚗蝏霈∠箇泵∩辣唳株撖寡情
+ * @return 曉靚
+ */
+ FDataFrameBuilder setSep(char sep);
+
/**
* 撠摰唳格亥砭箸
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/table/FDataFrame.java b/src_code/src/main/java/zhao/algorithmMagic/operands/table/FDataFrame.java
index cbf958c..154d45e 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/table/FDataFrame.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/table/FDataFrame.java
@@ -1,12 +1,16 @@
package zhao.algorithmMagic.operands.table;
import zhao.algorithmMagic.exception.OperatorOperationException;
+import zhao.algorithmMagic.io.InputComponent;
+import zhao.algorithmMagic.io.OutputComponent;
import zhao.algorithmMagic.utils.ASIO;
import zhao.algorithmMagic.utils.ASMath;
import zhao.algorithmMagic.utils.transformation.Transformation;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
+import java.io.PrintStream;
import java.sql.Connection;
import java.util.*;
@@ -91,6 +95,41 @@ public static FDataFrame select(Series colNameRow, int pk) {
).refreshField(false, true);
}
+ /**
+ * 雿輻函洵銝寞唳格颲亦隞嗉銵唳桃頧踝撟嗉瑕啣笆摨DataFrame撖寡情
+ *
+ * @param inputComponent 閬雿輻函蝚砌寞唳株亦隞嗅笆鞊
+ * @return 瑕啁DataFrame撖寡情
+ */
+ public static DataFrame builder(InputComponent inputComponent) {
+ if (inputComponent.open()) {
+ DataFrame dataFrame = inputComponent.getDataFrame();
+ ASIO.close(inputComponent);
+ return dataFrame;
+ }
+ throw new OperatorOperationException("inputComponent open error!!!");
+ }
+
+ /**
+ * 雿輻函洵銝寞唳格颲亦隞嗉銵唳桃頧踝撟嗉瑕啣笆摨DataFrame撖寡情
+ *
+ * @param inputComponent 閬雿輻函蝚砌寞唳株亦隞嗅笆鞊
+ * @param isOC 憒霈曄蔭銝 true 隞銵冽唳株亥挽憭撖寡情撘銝喲凋漱望嗥恣嚗典撠銝閬撖寧隞嗉銵撘喲剜雿嚗銋隞銵冽嗅芯蝙函隞塚雿銝隡撘銝喲剔隞嗅笆鞊∼
+ *
+ * If set to true, it means that the opening and closing of data input device objects are managed by the framework, and there will be no need to open or close components externally. Conversely, it means that the framework only uses components, but will not open or close component objects.
+ * @return 瑕啁DataFrame撖寡情
+ */
+ public static DataFrame builder(InputComponent inputComponent, boolean isOC) {
+ if (isOC) {
+ if (inputComponent.open()) {
+ DataFrame dataFrame = inputComponent.getDataFrame();
+ ASIO.close(inputComponent);
+ return dataFrame;
+ }
+ throw new OperatorOperationException("inputComponent open error!!!");
+ } else return inputComponent.getDataFrame();
+ }
+
/**
* 瑟啣畾菜唳殷冽唳桅銝剖恍撖寡摮畾萄蝘唳撱箇蝝WHash銵剁玖ash銵其葉摮畾菜嗅臭誑餈銵瑟啁嚗蝏餈瑟唬嚗摮畾萄銝隡瘨憭梧臭啣畾萄勗銝銝芣唳株嚗銝祆亥秩嚗銝湔寡摮畾萇萎撠銝隡靚刻砲賣啜
*
@@ -197,6 +236,9 @@ public DataFrame desc() {
*/
@Override
public DataFrame select(String... colNames) {
+ if (colNames.length == 1 && "*".equals(colNames[0])) {
+ return this;
+ }
ArrayList arrayList = new ArrayList<>(list.size() + 4);
int[] index = new int[colNames.length];
{
@@ -643,6 +685,109 @@ public DataFrame into_outHtml(String outPath, String tableName) {
return this;
}
+ /**
+ * 撠霈∠蝏靘蝏摰唳株箇隞嗉銵唳桃颲箸雿嚗
+ *
+ * @param outputComponent 颲箸唳桅閬雿輻函唳株箇隞
+ * @return 颲箔隡餈唳桅祈澈嚗銝隡蝏甇Z具
+ *
+ * After output, the data set itself will be returned and the call will not be terminated.
+ */
+ @Override
+ public DataFrame into_outComponent(OutputComponent outputComponent) {
+ if (outputComponent.open()) {
+ outputComponent.writeDataFrame(this);
+ ASIO.close(outputComponent);
+ } else throw new OperatorOperationException("into_outComponent(OutputComponent outputComponent) error!!!");
+ return this;
+ }
+
+ /**
+ * 暺霈斗孵亦 DF 唳桀笆鞊∩葉唳柴
+ *
+ * The default method is to view data in DF data objects.
+ */
+ @Override
+ public void show() {
+ this.show(System.out);
+ }
+
+ /**
+ * 湔亙刻箸銝剖曇”銝剔唳桀蝷箏箸伐貉鈭 toString 霂亙賣唳扯賣游隡蝘
+ *
+ * @param bufferedWriter 閬雿輻函唳株箸
+ */
+ @Override
+ public void show(BufferedWriter bufferedWriter) {
+ StringBuilder split = new StringBuilder();
+ StringBuilder field = new StringBuilder();
+ String s;
+ try {
+ s = getFieldRowStr(split, field);
+ bufferedWriter.append('\n')
+ .append(s)
+ .append(field)
+ .append('\n')
+ .write(s);
+ for (Series cells : this.list) {
+ bufferedWriter.write("\t\t");
+ for (Cell> cell : cells) {
+ bufferedWriter
+ .append(cell.getValue().toString())
+ .write("\t\t");
+ }
+ bufferedWriter.write('\n');
+ }
+ bufferedWriter.append(s);
+ } catch (IOException e) {
+ throw new OperatorOperationException(e);
+ }
+ }
+
+ public final String getFieldRowStr(StringBuilder split, StringBuilder field) {
+ String s;
+ split.append('');
+ field.append("\t\t");
+ for (Cell> cell : this.getFields()) {
+ field.append(cell.toString());
+ field.append("\t\t");
+ split.append("");
+ }
+ split.append('').append('\n');
+ s = split.toString();
+ return s;
+ }
+
+ /**
+ * 湔亙刻箸銝剖曇”銝剔唳桀蝷箏箸伐貉鈭 toString 霂亙賣唳扯賣游隡蝘
+ *
+ * @param printStream 閬雿輻函唳株箸
+ */
+ @Override
+ public void show(PrintStream printStream) {
+ StringBuilder split = new StringBuilder();
+ StringBuilder field = new StringBuilder();
+ String s;
+ {
+ s = getFieldRowStr(split, field);
+ printStream.append('\n')
+ .append(s)
+ .append(field)
+ .append('\n')
+ .append(s);
+ }
+ for (Series cells : this.list) {
+ printStream.append("\t\t");
+ for (Cell> cell : cells) {
+ printStream
+ .append(cell.getValue().toString())
+ .append("\t\t");
+ }
+ printStream.append('\n');
+ }
+ printStream.append(s);
+ }
+
/**
* 撠DF撖寡情銝剔唳株蓮X銝箔銝泓ist摰孵具
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/table/FDataFrameBuilder.java b/src_code/src/main/java/zhao/algorithmMagic/operands/table/FDataFrameBuilder.java
index 5627f15..72576ad 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/table/FDataFrameBuilder.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/table/FDataFrameBuilder.java
@@ -74,6 +74,7 @@ public FDataFrameBuilder setColNames(String[] colNames) {
* @param sep 摰唳桀蝚佗霂亙蝚血隡刻粉嗅鋡怨其瑕嚗蝏霈∠箇泵∩辣唳株撖寡情
* @return 曉靚
*/
+ @Override
public FDataFrameBuilder setSep(char sep) {
this.sep = sep;
return this;
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/table/FinalCell.java b/src_code/src/main/java/zhao/algorithmMagic/operands/table/FinalCell.java
index 1d98e28..1d6b074 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/table/FinalCell.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/table/FinalCell.java
@@ -3,6 +3,8 @@
import zhao.algorithmMagic.exception.OperatorOperationException;
import zhao.algorithmMagic.utils.ASStr;
+import java.util.Date;
+
/**
* 銝臬啣潛澆笆鞊∴霂交唳桃掩撠臬其銝芸潘撟嗅霈詨嗥掩臬瑞
*
@@ -76,6 +78,20 @@ public final int getIntValue() {
}
}
+ /**
+ * @return 敶潔葉摮函湔唳啣潛掩嚗霂交雿餈撠銝臬撖寡情
+ *
+ * The integer numeric type stored in the current cell. This operation will not return the original object.
+ */
+ @Override
+ public final long getLongValue() {
+ if (isNumber()) {
+ return ((Number) this.valueType).longValue();
+ } else {
+ throw new OperatorOperationException("典典霂撠銝銝芷啣潛潭扳湔啁孵嚗餈臭霈貊\nYou are trying to extract a non-numeric cell as an integer, which is not allowed.");
+ }
+ }
+
/**
* @return 敶潔葉摮函Double啣潛掩嚗霂交雿餈撠銝臬撖寡情
*
@@ -90,6 +106,22 @@ public final double getDoubleValue() {
}
}
+ /**
+ * @return 敶潔葉摮函 Date 啣潛掩嚗霂交雿餈撠銝臬撖寡情
+ *
+ * The Date numeric type stored in the current cell. This operation will not return the original object.
+ */
+ @Override
+ public Date getDate() {
+ if (isNumber()) {
+ return new Date(this.getLongValue());
+ } else {
+ if (this.valueType instanceof Date) return (Date) this.valueType;
+ else
+ throw new OperatorOperationException("冽瘜隞潔葉唳殷銝箏嗡撅鈭瘥怎啣潔銝撅鈭交撖寡情\nYou cannot extract data from a cell because it does not belong to a millisecond value or a date object.");
+ }
+ }
+
/**
* @return 敶潔葉摮函摮蝚虫葡啣潛掩嚗霂交雿餈撠銝臬撖寡情
*
diff --git a/src_code/src/main/java/zhao/algorithmMagic/operands/vector/SparkVector.scala b/src_code/src/main/java/zhao/algorithmMagic/operands/vector/SparkVector.scala
index 366e195..416767a 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/operands/vector/SparkVector.scala
+++ b/src_code/src/main/java/zhao/algorithmMagic/operands/vector/SparkVector.scala
@@ -77,14 +77,6 @@ final class SparkVector(sparkContext: SparkContext, vector: org.apache.spark.mll
else throw new OperatorOperationException("'DoubleVector1 innerProduct DoubleVector2' 塚銝支葵'DoubleVector'怎圈銝嚗DoubleVector1=[" + doubles1.length + "]嚗DoubleVector2=[" + doubles2.length + "]\n" + "When 'DoubleVector1 innerProduct DoubleVector2', the two vectors of 'DoubleVector' contain different quantities, DoubleVector1=[" + doubles1.length + "], DoubleVector2=[" + doubles2.length + "]")
}
- /**
- *
- * @return 撠砍笆鞊∩葉摮函摨啁瑁唬銝芣唳啁撟嗅唳啁餈嚗餈餈臭銝芣唳啁嚗舀靽格寧雿
- *
- * Copy the vector sequence array stored in this object to a new array and return the new array. Here, a new array is returned, which supports modification and other operations.
- */
- override def copyToNewArray(): Array[Double] = vector.toArray
-
/**
* @return 霂亦掩摰啁掩撖寡情嚗其撅霂交亙摮蝐
*/
@@ -115,13 +107,6 @@ final class SparkVector(sparkContext: SparkContext, vector: org.apache.spark.mll
else throw new OperatorOperationException("'DoubleVector1 add DoubleVector2' 塚銝支葵'DoubleVector'怎圈銝嚗DoubleVector1=[" + numberOfDimensions1 + "]嚗DoubleVector2=[" + numberOfDimensions2 + "]\n" + "When 'DoubleVector1 add DoubleVector2', the two vectors of 'DoubleVector' contain different quantities, DoubleVector1=[" + numberOfDimensions1 + "], DoubleVector2=[" + numberOfDimensions2 + "]")
}
- /**
- * @return 銝剖怎蝏游漲圈
- *
- * the number of dimensions contained in the vector
- */
- override def getNumberOfDimensions: Int = size
-
/**
* 其舅銝芣雿唬游撌桃寞嚗瑚冽霂瑕API霂湔
*
@@ -146,6 +131,21 @@ final class SparkVector(sparkContext: SparkContext, vector: org.apache.spark.mll
else throw new OperatorOperationException("'DoubleVector1 diff DoubleVector2' 塚銝支葵'DoubleVector'怎圈銝嚗DoubleVector1=[" + numberOfDimensions1 + "]嚗DoubleVector2=[" + numberOfDimensions2 + "]\n" + "When 'DoubleVector1 diff DoubleVector2', the two vectors of 'DoubleVector' contain different quantities, DoubleVector1=[" + numberOfDimensions1 + "], DoubleVector2=[" + numberOfDimensions2 + "]")
}
+ /**
+ *
+ * @return 撠砍笆鞊∩葉摮函摨啁瑁唬銝芣唳啁撟嗅唳啁餈嚗餈餈臭銝芣唳啁嚗舀靽格寧雿
+ *
+ * Copy the vector sequence array stored in this object to a new array and return the new array. Here, a new array is returned, which supports modification and other operations.
+ */
+ override def copyToNewArray(): Array[Double] = vector.toArray
+
+ /**
+ * @return 銝剖怎蝏游漲圈
+ *
+ * the number of dimensions contained in the vector
+ */
+ override def getNumberOfDimensions: Int = size
+
/**
*
* @return 蝚砌孵銝剜蝏湔斤摨嚗餈甇文賣唳典臭誑湔亥瑕啁洵銝孵銝剔撖寡情
diff --git a/src_code/src/main/java/zhao/algorithmMagic/utils/ASClass.java b/src_code/src/main/java/zhao/algorithmMagic/utils/ASClass.java
index 76a9317..abbc855 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/utils/ASClass.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/utils/ASClass.java
@@ -262,20 +262,14 @@ public static int[] DoubleArray_To_IntArray(double[] doubles) {
* @return 瑁摰啁撖寡情嚗嗆祈澈 dest
*/
public static int[][] array2DCopy(int[][] src, int[][] dest) {
- array2DCopy(src, dest, Math.min(src.length, dest.length));
+ int index = -1;
+ for (int[] objects : src) {
+ int[] res = dest[++index];
+ System.arraycopy(objects, 0, res, 0, Math.min(objects.length, res.length));
+ }
return dest;
}
- /**
- * 撠銝銝芯蝏湔啁銝剔唳桀瑟瑁唳啁鈭蝏湔啁銝
- *
- * @param src 閬鋡急瑁啁
- * @param dest 閬鋡急瑁格啁
- */
- private static void array2DCopy(int[][] src, int[][] dest, int length) {
- System.arraycopy(src, 0, dest, 0, length);
- }
-
/**
* 撠銝銝芯蝏湔啁銝剔唳桀瑟瑁唳啁鈭蝏湔啁銝
*
@@ -284,20 +278,14 @@ private static void array2DCopy(int[][] src, int[][] dest, int length) {
* @return 瑁摰啁撖寡情嚗嗆祈澈 dest
*/
public static double[][] array2DCopy(double[][] src, double[][] dest) {
- array2DCopy(src, dest, Math.min(src.length, dest.length));
+ int index = -1;
+ for (double[] objects : src) {
+ double[] res = dest[++index];
+ System.arraycopy(objects, 0, res, 0, Math.min(objects.length, res.length));
+ }
return dest;
}
- /**
- * 撠銝銝芯蝏湔啁銝剔唳桀瑟瑁唳啁鈭蝏湔啁銝
- *
- * @param src 閬鋡急瑁啁
- * @param dest 閬鋡急瑁格啁
- */
- private static void array2DCopy(double[][] src, double[][] dest, int length) {
- System.arraycopy(src, 0, dest, 0, length);
- }
-
/**
* 撠銝銝芯蝏湔啁銝剔唳桀瑟瑁唳啁鈭蝏湔啁銝
*
@@ -305,7 +293,11 @@ private static void array2DCopy(double[][] src, double[][] dest, int length) {
* @param dest 閬鋡急瑁格啁
*/
public static void array2DCopy(Object[][] src, Object[][] dest) {
- System.arraycopy(src, 0, dest, 0, Math.min(src.length, dest.length));
+ int index = -1;
+ for (Object[] objects : src) {
+ Object[] res = dest[++index];
+ System.arraycopy(objects, 0, res, 0, Math.min(objects.length, res.length));
+ }
}
/**
@@ -362,5 +354,4 @@ public static void mergeArray(arr[] res, arr[] arr1, arr[] arr2) {
}
}
}
-
}
\ No newline at end of file
diff --git a/src_code/src/main/java/zhao/algorithmMagic/utils/ASIO.java b/src_code/src/main/java/zhao/algorithmMagic/utils/ASIO.java
index e41f3e1..6c993e4 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/utils/ASIO.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/utils/ASIO.java
@@ -65,6 +65,18 @@ public static void writer(File path, Consumer voidTrans) {
}
}
+ /**
+ * 唳桃撌亙瑕賣堆霂亙賣啣蝞∠唳格
+ *
+ * @param outputStream 祆唳株箸
+ * @param voidTrans 祆唳株箔蝙刻箸
+ */
+ public static void writer(OutputStream outputStream, Consumer voidTrans) {
+ BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
+ voidTrans.accept(bufferedWriter);
+ ASIO.close(bufferedWriter);
+ }
+
/**
* 撠銝銝沱yte啁颲箏唳摰頝臬
*
@@ -148,7 +160,10 @@ public static Color[][] parseImageGetColorArray(String inputString) {
*/
public static Color[][] parseURLGetColorArray(URL imageUrl) {
try {
- return parseImageGetColorArray(ImageIO.read(imageUrl.openStream()));
+ InputStream inputStream = imageUrl.openStream();
+ Color[][] colors = parseImageGetColorArray(ImageIO.read(inputStream));
+ inputStream.close();
+ return colors;
} catch (IOException e) {
throw new OperatorOperationException(e);
}
@@ -181,7 +196,7 @@ public static Color[][] parseImageGetColorArray(File inputFile) throws IOExcepti
* @param image 閬鋡怨粉曉蝻脣笆鞊
* @return 霂餃銋餈游耦拚
*/
- private static Color[][] parseImageGetColorArray(BufferedImage image) {
+ public static Color[][] parseImageGetColorArray(BufferedImage image) {
final byte[] pixels = ((DataBufferByte) image.getRaster()
.getDataBuffer())
.getData();
@@ -235,6 +250,10 @@ private static Color[][] parseImageGetColorArray(BufferedImage image) {
*/
public static int[][] parseImageGetArray(File inputFile) throws IOException {
BufferedImage image = ImageIO.read(inputFile);
+ return parseImageGetArray(image);
+ }
+
+ public static int[][] parseImageGetArray(BufferedImage image) {
final byte[] pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
final int width = image.getWidth(), height = image.getHeight();
final boolean hasAlphaChannel = image.getAlphaRaster() != null;
@@ -316,4 +335,17 @@ public static IntegerMatrix[] parseImageGetArrays(File inputFile) throws IOExcep
IntegerMatrix.parse(RMat), IntegerMatrix.parse(GMat), IntegerMatrix.parse(BMat)
};
}
+
+ /**
+ * @param closeable 閬鋡怠喲剔撖寡情
+ */
+ public static void close(Closeable closeable) {
+ if (closeable != null) {
+ try {
+ closeable.close();
+ } catch (IOException ignored) {
+
+ }
+ }
+ }
}
diff --git a/src_code/src/main/java/zhao/algorithmMagic/utils/ASMath.java b/src_code/src/main/java/zhao/algorithmMagic/utils/ASMath.java
index 13e2ca1..c084087 100644
--- a/src_code/src/main/java/zhao/algorithmMagic/utils/ASMath.java
+++ b/src_code/src/main/java/zhao/algorithmMagic/utils/ASMath.java
@@ -63,6 +63,43 @@ public static int[] MaxAndMin(int[] doubles) {
return new int[]{max, min};
}
+ /**
+ * 霈∠銝銝芸憭批潔撠
+ *
+ * @param doubles 鋡怨恣蝞摨
+ * @return 霈∠蝏嚗蝚砌銝芸唳舀憭批潘蝚砌銝芸唳舀撠
+ */
+ public static double[] MaxAndMin(double[][] doubles) {
+ // 霈∠憭批潭撠
+ double max = doubles[0][0];
+ double min = doubles[0][0];
+ for (double[] aDouble : doubles) {
+ for (double v : aDouble) {
+ if (v > max) max = v;
+ if (v < min) min = v;
+ }
+ }
+ return new double[]{max, min};
+ }
+
+ /**
+ * 霈∠銝銝芸憭批潔撠
+ *
+ * @param doubles 鋡怨恣蝞摨
+ * @return 霈∠蝏嚗蝚砌銝芸唳舀憭批潘蝚砌銝芸唳舀撠
+ */
+ public static int[] MaxAndMin(int[][] doubles) {
+ // 霈∠憭批潭撠
+ int max = doubles[0][0];
+ int min = doubles[0][0];
+ for (int[] aDouble : doubles) {
+ for (int v : aDouble) {
+ if (v > max) max = v;
+ if (v < min) min = v;
+ }
+ }
+ return new int[]{max, min};
+ }
/**
* 霈∠銝銝芸銝剔憭批潭撠
diff --git a/src_code/src/main/java/zhao/algorithmMagic/utils/transformation/ProTransForm.java b/src_code/src/main/java/zhao/algorithmMagic/utils/transformation/ProTransForm.java
new file mode 100644
index 0000000..9293ee8
--- /dev/null
+++ b/src_code/src/main/java/zhao/algorithmMagic/utils/transformation/ProTransForm.java
@@ -0,0 +1,28 @@
+package zhao.algorithmMagic.utils.transformation;
+
+import zhao.algorithmMagic.operands.table.Cell;
+
+import java.util.HashMap;
+
+/**
+ * 撣血啁唳株蓮X亙蝐鳴嗡葉冽亙銝銝芷閬鋡怨蓮Y撖寡情銋餈閬隡銝銝芷蝵桀圈★
+ *
+ * A data conversion interface class with parameters, in which a configuration parameter item needs to be passed after receiving an object that needs to be converted.
+ *
+ * @author 韏萄摰
+ * 2023/4/5 9:05
+ */
+public interface ProTransForm {
+
+ /**
+ * @param inputType 亥芸函敺頧祆X唳柴
+ * Data to be converted from inside.
+ * @param value 頧祆X園閬雿輻函啣銵剁嗡葉key臬啣蝘堆value臬唳啣潛澆笆鞊∴臭誑撠鋆隞餅蝐餃唳殷銝祆萎嚗憒銝閬隡啣臭誑湔乩null
+ *
+ * The list of parameters that need to be used during conversion, where key is the parameter name and value is the cell object of the parameter value, which can encapsulate any type of data. Generally, if no parameters need to be passed, null can be passed directly.
+ * @return 頧祆V唳柴
+ *
+ * Data after conversion.
+ */
+ OutputType function(InputType inputType, HashMap> value);
+}
diff --git a/src_code/update/1.16_1.17-Chinese.md b/src_code/update/1.16_1.17-Chinese.md
new file mode 100644
index 0000000..58ce62c
--- /dev/null
+++ b/src_code/update/1.16_1.17-Chinese.md
@@ -0,0 +1,814 @@
+#  蝞瘜銋-箏典之
+
+- Switch to [English Document](https://github.com/BeardedManZhao/algorithmStar/blob/main/src_code/update/1.16_1.17.md)
+- knowledge base
+
+
+
+
+### 湔唳亙
+
+* 獢嗥穿1.16 - 1.17
+* 撠函蝘唬耨嫣蛹Integrator
+* 靘瑞妖賣啁霈∠舀嚗賢餈瑞妖賣啣孵曉之嗥憬撠曉拚萇蝝圈
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.integrator.ImageRenderingIntegrator;
+import zhao.algorithmMagic.integrator.launcher.ImageRenderingMarLauncher;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
+import zhao.algorithmMagic.operands.matrix.block.IntegerMatrixSpace;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ String s1 = "C:\\Users\\Liming\\Desktop\\fsDownload\\敺桐縑曄_1.jpg";
+ IntegerMatrix integerMatrix;
+ {
+ // 霈曄蔭
+ IntegerMatrix weight = IntegerMatrix.parse(
+ new int[]{0, -1},
+ new int[]{-1, 2},
+ new int[]{0, 0}
+ );
+ // 霂餃曉撟嗉瑕唬拚萇征
+ IntegerMatrixSpace parse = IntegerMatrixSpace.parse(s1);
+ // 撖孵曉餈銵瑞妖嚗瑕銝銝芾脣蔗拚萇征渡
+ integerMatrix = parse.foldingAndSum(2, 3, IntegerMatrixSpace.parse(weight, weight, weight));
+ }
+ // 颲箏曄1瑞妖曉隞
+ ImageRenderingIntegrator image = new ImageRenderingIntegrator(
+ "image",
+ new ImageRenderingMarLauncher<>(integerMatrix, "C:\\Users\\Liming\\Desktop\\fsDownload\\res12.jpg", 1)
+ );
+ if (image.run()) {
+ System.out.println("ok!!!");
+ }
+ }
+}
+```
+
+* 曉拚菜舀湔仿餈 show 賣啣典撟銝剜曄內箏曉
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+public class MAIN1 {
+ public static void main(String[] args) throws InterruptedException {
+ String s1 = "C:\\Users\\Liming\\Desktop\\fsDownload\\敺桐縑曄_1.jpg";
+ ColorMatrix parse = ColorMatrix.parse(s1);
+ parse.show("image");
+ Thread.sleep(1024);
+ parse.colorReversal(false);
+ parse.show("image");
+ }
+}
+```
+
+* 隡箸銋勗賣 shuffle 銝剔憭折箸銋望活啁瘜嚗雿踹嗡隡箇啗撘撣詻
+* 隡餈箄挪桃拚萎葉唳桃賣圈餉嚗玖ash餈銵啣撠
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColumnDoubleMatrix;
+
+import java.util.Arrays;
+import java.util.Random;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔隞賜拚菜唳
+ double[][] data = new double[][]{
+ new double[]{10, 11, 14, 10, 100},
+ new double[]{11, 11, 14, 10, 100},
+ new double[]{25, 20, 28, 20, 100},
+ new double[]{26, 20, 28, 20, 100}
+ };
+ // 撠拚菜唳桐蝙冽摰銝銵蝘啁孵撱箏箸
+ ColumnDoubleMatrix columnDoubleMatrix = ColumnDoubleMatrix.parse(
+ new String[]{"col1", "col2", "col3", "col4", "col5"},
+ new String[]{"row1", "row2", "row3", "row4"},
+ data
+ );
+ // 雿輻其撱箸啁拚萇孵銋勗嗡葉唳桅◇摨 銝憭銋 10 甈
+ columnDoubleMatrix.shuffle(new Random(), false, 10);
+ // 啣箇拚菜唳
+ System.out.println(columnDoubleMatrix);
+ // 啣箇拚萎葉 col2 冽啁銝剛砲賣圈撣摰 摨行敺
+ System.out.println(Arrays.toString(columnDoubleMatrix.getArrayByColName("col2")));
+ // 啣箇拚萎葉 row2 銵 冽啁銝剛砲賣圈撣摰 摨行敺
+ System.out.println(Arrays.toString(columnDoubleMatrix.getArrayByRowName("row2")));
+ }
+}
+```
+
+* 舀曉敹急瑚摮賣啁靚冽雿嚗雿踹曉隞嗥靽摮敺渡
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ String s1 = "C:\\Users\\zhao\\Desktop\\fsDownload\\敺桐縑曄_2.jpg";
+ // 瑕啣曉拚萄笆鞊
+ ColorMatrix parse = ColorMatrix.parse(s1);
+ // 撠曉典曉箇銝餈銵憸脣頧祆雿
+ parse.colorReversal(false);
+ // 亦憸脣頧砌曉
+ parse.show("image1");
+ // 颲箏頧砌曉
+ parse.save("C:\\Users\\zhao\\Desktop\\fsDownload\\res123.jpg");
+ }
+}
+```
+
+* 憓鈭 "SaveMatrix" 亙嚗摰唬霂交亙銝拚菟賢臭誑雿輻函蝏靽摮
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ String s1 = "C:\\Users\\Liming\\Desktop\\fsDownload\\敺桐縑曄_2.jpg";
+ // 瑕啣曉拚萄笆鞊
+ ColorMatrix parse = ColorMatrix.parse(s1);
+ // 颲箏曉RGB祆唳
+ parse.save("C:\\Users\\Liming\\Desktop\\fsDownload\\res1234.csv", ',');
+ }
+}
+```
+
+* AS摨銝剖鈭唳桀摨嚗雿輻沒QL憌澆唳殷餈霂亙臭誑嫣噶撠唳桀銝剔唳株瑕啣摮銝剛銵憭
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) throws SQLException {
+ // 憭唳桀餈亙笆鞊
+ Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.0.101:38243/tq_SCHOOL", "liming", "liming7887");
+ // 撠唳桀唳桀笆鞊∪頧賣 FDF
+ DataFrame execute = FDataFrame.builder(connection) // 摰唳桀餈
+ .create("*") // 摰亥砭摮畾
+ .from("STU_FIVE") // 摰亥砭銵
+ .primaryKey(0) // 摰摮AS銵函銝駁殷AS隡芸典遣蝡銵蝝W嚗唳桀亥砭閬雿輻函揣撘摰佗
+ .execute();// 撘憪亥砭
+ // 啣 FDF 銝剔唳
+ System.out.println(execute);
+
+ // 撘憪亥砭 FDF
+ // 甇摨啣 FDF 銝 name踹漲銝3鈭箏銝剔瑕戊鈭箸 啣箏 3 銵唳
+ DataFrame select = execute
+ .select("name", "sex") // 亥砭嗡葉 name sex
+ .where(v -> v.getCell(0).getStringValue().length() == 3) // 瑕啣嗡葉摮踹漲銝 3 唳株
+ .groupBy("sex") // sex 蝏
+ .count() // 撠瘥銝蝏餈銵蝏霈
+ .sort("count()") // 抒霈∠餈銵甇摨摨
+ .limit(3); // 瑕憭3銵唳
+ System.out.println(select.into_outfile("C:\\Users\\zhao\\Desktop\\fsDownload\\res1.csv"));
+ // 啣 FDF 銝剔唳株
+ System.out.println("唳株 = " + execute.count());
+ // 啣箏嗡葉靽⊥
+ System.out.println(execute.desc());
+ // 瑕 韏萄摰 靽⊥ 曹 name 臭蜓殷甇文臭誑湔仿餈餈瑕唳唳
+ System.out.println(execute.selectRow("韏萄摰"));
+ }
+}
+```
+
+* 雿輻 FDataFrame 頧賣唳桀銝隞嗡葉唳柴
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.*;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) throws SQLException {
+ // 憭唳桀餈亙笆鞊
+ Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.0.101:38243/tq_SCHOOL", "liming", "liming7887");
+ // 撠唳桀唳桀笆鞊∪頧賣 FDF
+ DataFrame execute = FDataFrame.builder(connection) // 摰唳桀餈
+ .create("*") // 摰亥砭摮畾
+ .from("STU_FIVE") // 摰亥砭銵
+ .where(" name = '韏萄摰' ") // 摰亥砭∩辣
+ .primaryKey(0) // 摰摮AS銵函銝駁殷AS隡芸典遣蝡銵蝝W嚗唳桀亥砭閬雿輻函揣撘摰佗
+ .execute();// 撘憪亥砭
+ // 啣 FDF 銝剔唳
+ System.out.println(execute);
+ }
+}
+```
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+
+import java.io.File;
+import java.sql.SQLException;
+import java.util.Objects;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 憭隞嗅笆鞊
+ File file = new File("C:\\Users\\zhao\\Desktop\\out\\res1.csv");
+ // 雿輻 FDF 頧賣隞
+ DataFrame execute1 = FDataFrame.builder(file)
+ // 隞嗅笆鞊∠霂餃閬摰砍蝚
+ .setSep(',')
+ // 隞嗅笆鞊⊿閬摰憟賢蝘堆銝賭蝙 * 餈隞銵函銝舀亥砭嚗臬撱箔銝枋F摮畾
+ .create("id", "name", "sex")
+ // 隞嗅笆鞊⊿閬雿輻甸ambda銵刻噢撘餈銵唳桃餈皛
+ .where(v -> Objects.equals(v.getCell(1).getStringValue(), "韏萄摰"))
+ // 隞嗅笆鞊∠銝駁格摰霈訾蝙典蝘
+ .primaryKey("name")
+ // 扯亥砭
+ .execute();
+ // 啣箇唳
+ System.out.println(execute1);
+ }
+}
+ ```
+
+* 撖達DF扯蝘啗銵limit雿
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+
+import java.io.File;
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 憭隞嗅笆鞊
+ File file = new File("C:\\Users\\zhao\\Desktop\\out\\res1.csv");
+ // 雿輻 FDF 頧賣隞
+ DataFrame execute1 = FDataFrame.builder(file)
+ // 隞嗅笆鞊∠霂餃閬摰砍蝚
+ .setSep(',')
+ // 隞嗅笆鞊⊿閬摰憟賢蝘堆銝賭蝙 * 餈隞銵函銝舀亥砭嚗臬撱箔銝枋F摮畾
+ .create("id", "name", "sex")
+ // 隞嗅笆鞊∠銝駁格摰霈訾蝙典蝘
+ .primaryKey("name")
+ // 扯亥砭
+ .execute();
+ // 啣箇唳 餈啣箔 韏 韐 銋渡唳株
+ System.out.println(execute1.limit("韏", "韐"));
+ }
+}
+```
+
+* 舀銝箏怠隞亙啣唳株雿
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+import zhao.algorithmMagic.operands.table.FieldCell;
+import zhao.algorithmMagic.operands.table.FinalSeries;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 憭隞嗅笆鞊
+ File file = new File("C:\\Users\\zhao\\Desktop\\out\\res1.csv");
+ // 雿輻 FDF 頧賣隞
+ DataFrame execute1 = FDataFrame.builder(file)
+ // 隞嗅笆鞊∠霂餃閬摰砍蝚
+ .setSep(',')
+ // 隞嗅笆鞊⊿閬摰憟賢蝘堆銝賭蝙 * 餈隞銵函銝舀亥砭嚗臬撱箔銝枋F摮畾
+ .create("id", "name", "sex")
+ // 隞嗅笆鞊∠銝駁格摰霈訾蝙典蝘
+ .primaryKey("name")
+ // 扯亥砭
+ .execute();
+ // 扳批怠蝏嚗霈∠箇瑕戊鈭箸
+ long start = System.currentTimeMillis();
+ System.out.println(
+ execute1
+ // 摰亥砭嚗撟嗉絲怠
+ .select(FieldCell.$("sex").as("批"))
+ // sex 蝏
+ .groupBy("批")
+ // 餈銵 蝏霈⊥
+ .count()
+ // 摰亥砭 撟嗉絲怠
+ .select(
+ FieldCell.$("批"),
+ FieldCell.$("count()").as("鈭箸")
+ )
+ // 啣銝銵唳
+ .insert(FinalSeries.parse("", "10"))
+ );
+ System.out.print("憭塚MS嚗嚗");
+ System.out.println(System.currentTimeMillis() - start);
+ }
+}
+
+```
+
+* 賢撖道F唳桅撖寡情銝剔啣潸銵銵唳桃賣啣湔堆嗆舀DF唳桀笆鞊∪啁拚萎渡頧祆U
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+import zhao.algorithmMagic.operands.table.FieldCell;
+import zhao.algorithmMagic.operands.table.FinalCell;
+import zhao.algorithmMagic.operands.vector.IntegerVector;
+
+import java.io.File;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 憭隞嗅笆鞊
+ File file = new File("C:\\Users\\zhao\\Desktop\\out\\res1.csv");
+ // 雿輻 FDF 頧賣隞
+ DataFrame execute1 = FDataFrame.builder(file)
+ // 隞嗅笆鞊∠霂餃閬摰砍蝚
+ .setSep(',')
+ // 隞嗅笆鞊⊿閬摰憟賢蝘堆銝賭蝙 * 餈隞銵函銝舀亥砭嚗臬撱箔銝枋F摮畾
+ .create("id", "name", "sex")
+ // 隞嗅笆鞊∠銝駁格摰霈訾蝙典蝘
+ .primaryKey("name")
+ // 扯亥砭
+ .execute()
+ // 銝箏韏瑕怠
+ .select(
+ FieldCell.$("id"),
+ FieldCell.$("name").as("蝘"),
+ FieldCell.$("sex").as("批")
+ )
+ // 撠批怠餈銵頧祆g瑞銝1 憟喟銝0
+ .updateCol(FieldCell.$("批"), cell -> new FinalCell<>(cell.getStringValue().equals("") ? 1 : 0))
+ // 撠銵銝駁格啣潔蛹ZLY唳株銝剔潭踵X銝箸唳 405
+ .updateRow("ZLY", cell -> new FinalCell<>(405));
+
+ // 啣箄”銝剔銵銝駁桀蝘唬蛹 405 唳株
+ System.out.println(execute1.selectRow("405"));
+ long start = System.currentTimeMillis();
+ // 撠銵刻蓮X銝箔銝芣游耦拚萄笆鞊∴霂交雿隡撠DF撖寡情銝剔啣潸曇蓮X銝 col.count()*3 拚萄笆鞊
+ IntegerMatrix parse = IntegerMatrix.parse(execute1, execute1.count().getIntValue(), 3);
+ System.out.println(IntegerVector.parse(parse.getArrayByColIndex(2)));
+ System.out.print("憭塚MS嚗嚗");
+ System.out.println(System.currentTimeMillis() - start);
+ }
+}
+```
+
+* 舀餈銝銝芰蝏 URL 撖寡情瑕唳喳曉唳殷撟嗅嗉蓮X銝箔銝芸曉拚萸
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class MAIN1 {
+ public static void main(String[] args) throws MalformedURLException {
+ // 憭曉URL撖寡情
+ URL url = new URL("https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png");
+ // 閫URL瑕啣曉拚
+ ColorMatrix parse1 = ColorMatrix.parse(url);
+ // 閫URL瑕啣曉啣漲拚
+ ColorMatrix parse2 = ColorMatrix.parseGrayscale(url);
+ // 亦曉
+ parse1.show("image");
+ parse2.show("image");
+ }
+}
+```
+
+* 舀餈銵脣蔗鈭澆閫渲嚗賢餈摰脣蔗啣潘曄內箸游曉孵嚗駁斗游雿孵
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class MAIN1 {
+ public static void main(String[] args) throws MalformedURLException {
+ // 憭曉URL撖寡情
+ URL url = new URL("https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png");
+ // 閫URL瑕啣曉拚
+ ColorMatrix parse1 = ColorMatrix.parse(url);
+ // 撠 URL 曉拚萎葉 G 憸脫啣澆之鈭 40 憸脣港蛹暺莎銋港蛹質
+ // 刻曹拐 G 甇 蝏輯脰瘛 頞航賢銝箇質
+ parse1.globalBinary(ColorMatrix._G_, 40, 0, 0xffffff);
+ // 銋臭誑雿輻典嗅憸脤餈銵脣蔗靚
+ parse1.globalBinary(ColorMatrix._R_, 40, 0, 0xffffff);
+ parse1.globalBinary(ColorMatrix._B_, 40, 0, 0xffffff);
+ // 亦蝏曉
+ parse1.show("image");
+ }
+}
+```
+
+* 舀餈銵曉 ASCII 曄嚗典臭誑敹恍撠銝銝芸曄 ASCII 箸伐銝餈霂瑟函&靽曉撠箏站頞喳撠
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class MAIN1 {
+ public static void main(String[] args) throws MalformedURLException {
+ // 憭曉URL撖寡情
+ URL url = new URL("https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png");
+ // 閫URL瑕啣曉拚
+ ColorMatrix parse1 = ColorMatrix.parse(url);
+ // 亦蝏曉
+ parse1.show("image");
+ // 颲箏曉 ASCII 啣潘颲箄銝 G 憸脫啣 憭找 40 颲箇泵 'A' 嗅颲箇泵 ' '
+ parse1.save(
+ new File("C:\\Users\\zhao\\Desktop\\fsDownload\\res.txt"),
+ ColorMatrix._G_, 40, 'A', ' '
+ );
+ }
+}
+```
+
+* 賢典撱箔銝芰征 DataFrame 撖寡情嚗撟嗉芯蜓雿嗡葉唳柴
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+import zhao.algorithmMagic.operands.table.FieldCell;
+import zhao.algorithmMagic.operands.table.FinalSeries;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DF 撖寡情 隞 name 雿銝箄銝駁桃揣撘
+ FDataFrame create = FDataFrame.select(FieldCell.parse("name", "sex", "phoneNum"), 1);
+ // 乩鈭唳
+ DataFrame insert = create.insert(
+ FinalSeries.parse("zhao", "M", "110xxxxxxxx"),
+ FinalSeries.parse("tang", "W", "110xxxxxxxx"),
+ FinalSeries.parse("yang", "M", "110xxxxxxxx")
+ );
+ // 亦唳桅
+ System.out.println(insert);
+ // 撠嗡葉 name sex 亥砭
+ System.out.println(
+ insert.select(
+ FieldCell.$("name").as("AllName"),
+ FieldCell.$("sex").as("AllSex")
+ )
+ );
+ }
+}
+```
+
+* 舀 group 嗅摰 where摮伐雿踹霈∠憭批之憓撘
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+import zhao.algorithmMagic.operands.table.FieldCell;
+import zhao.algorithmMagic.operands.table.FinalSeries;
+
+import java.net.MalformedURLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DF 撖寡情 隞 name 雿銝箄銝駁桃揣撘
+ FDataFrame create = FDataFrame.select(FieldCell.parse("name", "sex", "phoneNum"), 1);
+ // 乩鈭唳
+ DataFrame insert = create.insert(
+ FinalSeries.parse("zhao1", "M", "110xxxxxxxx"),
+ FinalSeries.parse("tang2", "W", "120xxxxxxxx"),
+ FinalSeries.parse("yang3", "W", "110xxxxxxxx"),
+ FinalSeries.parse("zhao4", "M", "120xxxxxxxx"),
+ FinalSeries.parse("tang5", "W", "110xxxxxxxx"),
+ FinalSeries.parse("yang6", "W", "110xxxxxxxx"),
+ FinalSeries.parse("zhao7", "M", "120xxxxxxxx"),
+ FinalSeries.parse("tang8", "W", "110xxxxxxxx"),
+ FinalSeries.parse("yang9", "W", "110xxxxxxxx")
+ );
+ // 亦唳桅
+ System.out.println(insert);
+ // 撠嗡葉箏瑕銝雿銝銝 120 唳株批嗡葉 sex 蝏 刻湔乩蝙典蝏嗉皛文喳
+ System.out.println(
+ insert.groupBy("sex", v -> {
+ // 瑕唳箏瑞摮蝚虫葡
+ String s = v.getCell(2).toString();
+ // 斗剖 3 銝芸蝚行臬虫蛹 120 嚗臬虫誑 120 撘憭湛 憒臬停銝瘛餃
+ return !s.startsWith("120");
+ }).count()
+ );
+ }
+}
+```
+
+* 舀撅其澆雿嚗賢啣啣曉鈭澆憭嚗貉鈭典鈭澆嚗賣唳游菜暑
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class MAIN1 {
+ public static void main(String[] args) throws MalformedURLException {
+ // 瑕啣曉拚
+ ColorMatrix parse = ColorMatrix.parse(new URL("https://img-blog.csdnimg.cn/img_convert/5765bdab08ef6e117d434e7e225b9013.png"));
+ parse.show("image");
+ System.out.println("ok!!!");
+ System.out.println(" = " + parse.getRowCount());
+ System.out.println("摰 = " + parse.getColCount());
+ // 撠曉餈銵撅其澆
+ parse.localBinary(
+ // 摰祆活鈭澆拍憸脤
+ ColorMatrix._G_,
+ // 摰祆活鈭澆箇撅典曉拚菜圈
+ 100,
+ // 摰祆活鈭澆銝剖函拚萎葉憭找撅券潛憸脩
+ 0xffffff,
+ // 摰祆活鈭澆銝剖函拚萎葉撠鈭撅券潛憸脩
+ 0,
+ // 摰祆活鈭澆銝剖券潛閬餈銵敺株啣潘餈舫雿20銝芷潭啣
+ -30
+ );
+ // 亦蝏唳
+ parse.show("image");
+ }
+}
+```
+
+* DF撖寡情唳格舀靽摮銝 HTML 隞塚賢摰唳芸典憿菟Y嗆雿
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+import zhao.algorithmMagic.operands.table.FieldCell;
+import zhao.algorithmMagic.operands.table.FinalSeries;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DF 撖寡情 隞 name 雿銝箄銝駁桃揣撘
+ FDataFrame create = FDataFrame.select(FieldCell.parse("name", "sex", "phoneNum", "salary"), 1);
+ // 乩鈭唳
+ DataFrame insert = create.insert(
+ FinalSeries.parse("zhao1", "M", "110xxxxxxxx", "30000"),
+ FinalSeries.parse("tang2", "W", "120xxxxxxxx", "30000"),
+ FinalSeries.parse("yang3", "W", "110xxxxxxxx", "30000"),
+ FinalSeries.parse("zhao4", "M", "120xxxxxxxx", "30000"),
+ FinalSeries.parse("tang5", "W", "110xxxxxxxx", "30000"),
+ FinalSeries.parse("yang6", "W", "110xxxxxxxx", "30000"),
+ FinalSeries.parse("zhao7", "M", "120xxxxxxxx", "30000"),
+ FinalSeries.parse("tang8", "W", "110xxxxxxxx", "30000"),
+ FinalSeries.parse("yang9", "W", "110xxxxxxxx", "30000")
+ );
+ // 颲箄”HTML 嗅亦銵其葉唳
+ System.out.println(
+ insert.into_outHtml("C:\\Users\\Liming\\Desktop\\fsDownload\\res11234.html", "myTable")
+ );
+ }
+}
+```
+
+* 曉撘憪舀 add 賣堆災dd賣啁雿銝嚗臭誑摰啣曉賣啁撟塚
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撠銝鈭曉隞嗉蓮X銝箔銝芸曉拚萄笆鞊
+ ColorMatrix colorMatrix1 = ColorMatrix.parse("C:\\Users\\Liming\\Desktop\\fsDownload\\test.bmp");
+ ColorMatrix colorMatrix2 = ColorMatrix.parse("C:\\Users\\Liming\\Desktop\\fsDownload\\test1.bmp");
+ // 撠 colorMatrix2 + colorMatrix1 蝏曉撅蝷箏箸
+ (colorMatrix1.add(colorMatrix2)).show("image");
+ }
+}
+```
+
+* 舀芸銋隞亙蝵格唳格寞雿
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撠銝鈭曉隞嗉蓮X銝箔銝芸曉拚萄笆鞊
+ ColorMatrix colorMatrix1 = ColorMatrix.parse("C:\\Users\\Liming\\Desktop\\fsDownload\\test.bmp");
+ ColorMatrix colorMatrix2 = ColorMatrix.parse("C:\\Users\\Liming\\Desktop\\fsDownload\\test1.bmp");
+ // 雿輻 agg 賣唬誑蝵桃霈∠寞餈銵銝支葵拚萇撟
+ // 銝W賣唬葉蝚砌銝芸耦隞銵函撠望舐拚萎葉蝝餉嚗餈雿輻函舀嚗撟嗅笆頞憸脫啣潸銵閫渡餉摰
+ colorMatrix1.agg(colorMatrix2, ColorMatrix.COLOR_SUM_REGULATE).show("image");
+ }
+}
+```
+
+* 曉拚菜舀餈蝞賣堆刻砲賣唬葉臭誑駁斗雿孵唳柴
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.sql.SQLException;
+
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撠銝鈭曉隞嗉蓮X銝箔銝芸曉拚萄笆鞊
+ ColorMatrix colorMatrix1 = ColorMatrix.parseGrayscale("C:\\Users\\Liming\\Desktop\\fsDownload\\test2.bmp");
+ // 撖孵曉餈銵鈭澆
+ colorMatrix1.globalBinary(ColorMatrix._G_, 100, 0xffffff, 0);
+ colorMatrix1.show("銋 image");
+ // 撘憪撖孵曉拚菔銵雿
+ colorMatrix1.erode(2, 2, false).show("銋 image");
+ }
+}
+```
+
+* 舀瘛餃嚗雿舫閬瘜冽臬瘛餃隡餈銝銝芣啁 DataFrame DF銝剔唳桀隡鋡急瑁箸乓
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.*;
+
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DataFrame 撖寡情
+ FDataFrame select = FDataFrame.select(
+ FieldCell.parse("id", "name", "sex", "age"), 1
+ );
+ // 冽交唳
+ select.insert(
+ FinalSeries.parse("1", "zhao", "M", "19"),
+ FinalSeries.parse("2", "tang", "W", "18"),
+ FinalSeries.parse("3", "yang", "W", "20"),
+ FinalSeries.parse("4", "shen", "W", "19")
+ );
+ // 啣 DF 撖寡情喟靽⊥
+ System.out.println(
+ select.desc()
+ );
+ // 瘛餃銝唳殷其銵函內撟湧臬虫蛹嗆
+ DataFrame ageIsE = select.insertColGetNew(
+ // 啣蝘
+ FieldCell.$("AgeIsE"),
+ // 啣啣潛餉 憒蝚 4 嚗index == 3嚗啣 % 2 == 0 撠望眩rue
+ cells -> cells.getCell(3).getIntValue() % 2 == 0 ? new FinalCell<>(true) : new FinalCell<>(false)
+ );
+ System.out.println(ageIsE);
+ }
+}
+```
+
+* 舀銵冽唳桐渡餈蝞雿嚗賢撠銵其葉啣潛掩餈銵瘙銝撌株恣蝞嚗霈∠銋撠餈蚤F撖寡情
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.*;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DataFrame 撖寡情
+ FDataFrame select1 = FDataFrame.select(
+ FieldCell.parse("id", "name", "sex", "age"), 1
+ );
+ // 冽交唳
+ select1.insert(
+ FinalSeries.parse("1", "zhao", "M", "19"),
+ FinalSeries.parse("2", "tang", "W", "18"),
+ FinalSeries.parse("3", "yang", "W", "20"),
+ FinalSeries.parse("4", "shen", "W", "19")
+ );
+ // 撱箔銝芰征 DataFrame 撖寡情
+ FDataFrame select2 = FDataFrame.select(
+ FieldCell.parse("id", "name", "sex", "age"), 1
+ );
+ // 冽交唳
+ select2.insert(
+ FinalSeries.parse("1", "zhao", "M", "19"),
+ FinalSeries.parse("2", "tang", "W", "18"),
+ FinalSeries.parse("3", "yang", "W", "20")
+ );
+ // 餈銵瘙銝撌桃餈蝞雿
+ System.out.println(select1.add(select2));
+ System.out.println(select1.diff(select2));
+ }
+}
+```
+
+* DataFrame唳桀笆鞊⊥摰撟
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.*;
+
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DataFrame 撖寡情
+ FDataFrame select = FDataFrame.select(
+ FieldCell.parse("id", "name", "sex", "age"), 1
+ );
+ // 冽交唳 嗅餈銵蝏
+ GroupDataFrameData groupDataFrameData = select.insert(
+ FinalSeries.parse("1", "zhao", "M", "19"),
+ FinalSeries.parse("2", "tang", "W", "18"),
+ FinalSeries.parse("3", "yang", "W", "20")
+ ).groupBy("sex");
+ // 啣 M 蝏唳
+ System.out.println(groupDataFrameData.getDFByGroup("M"));
+ // 啣 W 蝏唳
+ System.out.println(groupDataFrameData.getDFByGroup("W"));
+ }
+}
+```
+
+* 啁祆釣鈭憿對甇斤砌葉靘韏鋡急霈唬蛹 provided 餈瑕臭誑憭批雿雿蝔摨佗賢寞株芸楛摰憿寧格亥銵詨喟蝵殷甇文刻銵AS摨瘜典亦嗅霂瑕隞乩敹憿駁★銝桀紡乓
+
+```xml
+
+
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ 2.20.0
+
+
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.20.0
+
+
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.20.0
+
+
+
+```
+
+### Version update date : 2023-03-26
\ No newline at end of file
diff --git a/src_code/update/1.16_1.17.md b/src_code/update/1.16_1.17.md
new file mode 100644
index 0000000..e9e3e81
--- /dev/null
+++ b/src_code/update/1.16_1.17.md
@@ -0,0 +1,791 @@
+#  Algorithm Star-MachineBrain
+
+- W [銝剜獢β(https://github.com/BeardedManZhao/algorithmStar/blob/main/src_code/update/1.16_1.17-Chinese.md)
+- knowledge base
+
+
+
+
+### Update log:
+
+* Framework version: 1.16 - 1.17
+* Change the name of the integrator to Integrator.
+* It provides the calculation support of convolution function, which can enlarge the features and reduce the number of
+ elements in the image matrix.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.integrator.ImageRenderingIntegrator;
+import zhao.algorithmMagic.integrator.launcher.ImageRenderingMarLauncher;
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
+import zhao.algorithmMagic.operands.matrix.block.IntegerMatrixSpace;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ String s1 = "C:\\Users\\Liming\\Desktop\\fsDownload\\敺桐縑曄_1.jpg";
+ IntegerMatrix integerMatrix;
+ {
+ // 霈曄蔭
+ IntegerMatrix weight = IntegerMatrix.parse(
+ new int[]{0, -1},
+ new int[]{-1, 2},
+ new int[]{0, 0}
+ );
+ // 霂餃曉撟嗉瑕唬拚萇征
+ IntegerMatrixSpace parse = IntegerMatrixSpace.parse(s1);
+ // 撖孵曉餈銵瑞妖嚗瑕銝銝芾脣蔗拚萇征渡
+ integerMatrix = parse.foldingAndSum(2, 3, IntegerMatrixSpace.parse(weight, weight, weight));
+ }
+ // 颲箏曄1瑞妖曉隞
+ ImageRenderingIntegrator image = new ImageRenderingIntegrator(
+ "image",
+ new ImageRenderingMarLauncher<>(integerMatrix, "C:\\Users\\Liming\\Desktop\\fsDownload\\res12.jpg", 1)
+ );
+ if (image.run()) {
+ System.out.println("ok!!!");
+ }
+ }
+}
+```
+
+* The image matrix supports displaying images on the screen directly through the show function.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+public class MAIN1 {
+ public static void main(String[] args) throws InterruptedException {
+ String s1 = "C:\\Users\\Liming\\Desktop\\fsDownload\\敺桐縑曄_1.jpg";
+ ColorMatrix parse = ColorMatrix.parse(s1);
+ parse.show("image");
+ Thread.sleep(1024);
+ parse.colorReversal(false);
+ parse.show("image");
+ }
+}
+```
+
+* Optimize the algorithm of maximum random scrambling times in the random scrambling function shuffle, so that it will
+ not have out-of-bounds exceptions.
+* Optimize the function logic of random access to data in the matrix through column names, and use hash to map
+ addresses.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColumnDoubleMatrix;
+
+import java.util.Arrays;
+import java.util.Random;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔隞賜拚菜唳
+ double[][] data = new double[][]{
+ new double[]{10, 11, 14, 10, 100},
+ new double[]{11, 11, 14, 10, 100},
+ new double[]{25, 20, 28, 20, 100},
+ new double[]{26, 20, 28, 20, 100}
+ };
+ // 撠拚菜唳桐蝙冽摰銝銵蝘啁孵撱箏箸
+ ColumnDoubleMatrix columnDoubleMatrix = ColumnDoubleMatrix.parse(
+ new String[]{"col1", "col2", "col3", "col4", "col5"},
+ new String[]{"row1", "row2", "row3", "row4"},
+ data
+ );
+ // 雿輻其撱箸啁拚萇孵銋勗嗡葉唳桅◇摨 銝憭銋 10 甈
+ columnDoubleMatrix.shuffle(new Random(), false, 10);
+ // 啣箇拚菜唳
+ System.out.println(columnDoubleMatrix);
+ // 啣箇拚萎葉 col2 冽啁銝剛砲賣圈撣摰 摨行敺
+ System.out.println(Arrays.toString(columnDoubleMatrix.getArrayByColName("col2")));
+ // 啣箇拚萎葉 row2 銵 冽啁銝剛砲賣圈撣摰 摨行敺
+ System.out.println(Arrays.toString(columnDoubleMatrix.getArrayByRowName("row2")));
+ }
+}
+```
+
+* It supports the call operation of the quick save function of the image, making the saving of the image file easier.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ String s1 = "C:\\Users\\zhao\\Desktop\\fsDownload\\敺桐縑曄_2.jpg";
+ // 瑕啣曉拚萄笆鞊
+ ColorMatrix parse = ColorMatrix.parse(s1);
+ // 撠曉典曉箇銝餈銵憸脣頧祆雿
+ parse.colorReversal(false);
+ // 亦憸脣頧砌曉
+ parse.show("image1");
+ // 颲箏頧砌曉
+ parse.save("C:\\Users\\zhao\\Desktop\\fsDownload\\res123.jpg");
+ }
+}
+```
+
+* The "SaveMatrix" interface is added. All matrices that implement this interface can be saved in structured or
+ unstructured way.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ String s1 = "C:\\Users\\Liming\\Desktop\\fsDownload\\敺桐縑曄_2.jpg";
+ // 瑕啣曉拚萄笆鞊
+ ColorMatrix parse = ColorMatrix.parse(s1);
+ // 颲箏曉RGB祆唳
+ parse.save("C:\\Users\\Liming\\Desktop\\fsDownload\\res1234.csv", ',');
+ }
+}
+```
+
+* A data analysis library is added to the AS library, which uses SQL styles to process data. Through this library, data
+ in the database can be easily obtained into memory for processing.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) throws SQLException {
+ // 憭唳桀餈亙笆鞊
+ Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.0.101:38243/tq_SCHOOL", "liming", "liming7887");
+ // 撠唳桀唳桀笆鞊∪頧賣 FDF
+ DataFrame execute = FDataFrame.builder(connection) // 摰唳桀餈
+ .create("*") // 摰亥砭摮畾
+ .from("STU_FIVE") // 摰亥砭銵
+ .primaryKey(0) // 摰摮AS銵函銝駁殷AS隡芸典遣蝡銵蝝W嚗唳桀亥砭閬雿輻函揣撘摰佗
+ .execute();// 撘憪亥砭
+ // 啣 FDF 銝剔唳
+ System.out.println(execute);
+
+ // 撘憪亥砭 FDF
+ // 甇摨啣 FDF 銝 name踹漲銝3鈭箏銝剔瑕戊鈭箸 啣箏 3 銵唳
+ DataFrame select = execute
+ .select("name", "sex") // 亥砭嗡葉 name sex
+ .where(v -> v.getCell(0).getStringValue().length() == 3) // 瑕啣嗡葉摮踹漲銝 3 唳株
+ .groupBy("sex") // sex 蝏
+ .count() // 撠瘥銝蝏餈銵蝏霈
+ .sort("count()") // 抒霈∠餈銵甇摨摨
+ .limit(3); // 瑕憭3銵唳
+ System.out.println(select.into_outfile("C:\\Users\\zhao\\Desktop\\fsDownload\\res1.csv"));
+ // 啣 FDF 銝剔唳株
+ System.out.println("唳株 = " + execute.count());
+ // 啣箏嗡葉靽⊥
+ System.out.println(execute.desc());
+ // 瑕 韏萄摰 靽⊥ 曹 name 臭蜓殷甇文臭誑湔仿餈餈瑕唳唳
+ System.out.println(execute.selectRow("韏萄摰"));
+ }
+}
+```
+
+* Use FDataFrame to load the data in the database and file.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.*;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) throws SQLException {
+ // 憭唳桀餈亙笆鞊
+ Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.0.101:38243/tq_SCHOOL", "liming", "liming7887");
+ // 撠唳桀唳桀笆鞊∪頧賣 FDF
+ DataFrame execute = FDataFrame.builder(connection) // 摰唳桀餈
+ .create("*") // 摰亥砭摮畾
+ .from("STU_FIVE") // 摰亥砭銵
+ .where(" name = '韏萄摰' ") // 摰亥砭∩辣
+ .primaryKey(0) // 摰摮AS銵函銝駁殷AS隡芸典遣蝡銵蝝W嚗唳桀亥砭閬雿輻函揣撘摰佗
+ .execute();// 撘憪亥砭
+ // 啣 FDF 銝剔唳
+ System.out.println(execute);
+ }
+}
+```
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+
+import java.io.File;
+import java.sql.SQLException;
+import java.util.Objects;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 憭隞嗅笆鞊
+ File file = new File("C:\\Users\\zhao\\Desktop\\out\\res1.csv");
+ // 雿輻 FDF 頧賣隞
+ DataFrame execute1 = FDataFrame.builder(file)
+ // 隞嗅笆鞊∠霂餃閬摰砍蝚
+ .setSep(',')
+ // 隞嗅笆鞊⊿閬摰憟賢蝘堆銝賭蝙 * 餈隞銵函銝舀亥砭嚗臬撱箔銝枋F摮畾
+ .create("id", "name", "sex")
+ // 隞嗅笆鞊⊿閬雿輻甸ambda銵刻噢撘餈銵唳桃餈皛
+ .where(v -> Objects.equals(v.getCell(1).getStringValue(), "韏萄摰"))
+ // 隞嗅笆鞊∠銝駁格摰霈訾蝙典蝘
+ .primaryKey("name")
+ // 扯亥砭
+ .execute();
+ // 啣箇唳
+ System.out.println(execute1);
+ }
+}
+ ```
+
+* Limit FDF by line name
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+
+import java.io.File;
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 憭隞嗅笆鞊
+ File file = new File("C:\\Users\\zhao\\Desktop\\out\\res1.csv");
+ // 雿輻 FDF 頧賣隞
+ DataFrame execute1 = FDataFrame.builder(file)
+ // 隞嗅笆鞊∠霂餃閬摰砍蝚
+ .setSep(',')
+ // 隞嗅笆鞊⊿閬摰憟賢蝘堆銝賭蝙 * 餈隞銵函銝舀亥砭嚗臬撱箔銝枋F摮畾
+ .create("id", "name", "sex")
+ // 隞嗅笆鞊∠銝駁格摰霈訾蝙典蝘
+ .primaryKey("name")
+ // 扯亥砭
+ .execute();
+ // 啣箇唳 餈啣箔 韏 韐 銋渡唳株
+ System.out.println(execute1.limit("韏", "韐"));
+ }
+}
+```
+
+* Support the operations of aliasing columns and adding data rows.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+import zhao.algorithmMagic.operands.table.FieldCell;
+
+import java.io.File;
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 憭隞嗅笆鞊
+ File file = new File("C:\\Users\\zhao\\Desktop\\out\\res1.csv");
+ // 雿輻 FDF 頧賣隞
+ DataFrame execute1 = FDataFrame.builder(file)
+ // 隞嗅笆鞊∠霂餃閬摰砍蝚
+ .setSep(',')
+ // 隞嗅笆鞊⊿閬摰憟賢蝘堆銝賭蝙 * 餈隞銵函銝舀亥砭嚗臬撱箔銝枋F摮畾
+ .create("id", "name", "sex")
+ // 隞嗅笆鞊∠銝駁格摰霈訾蝙典蝘
+ .primaryKey("name")
+ // 扯亥砭
+ .execute();
+ // 扳批怠蝏嚗霈∠箇瑕戊鈭箸
+ System.out.println(
+ execute1
+ // 摰亥砭嚗撟嗉絲怠
+ .select(FieldCell.$("sex").as("批"))
+ // sex 蝏
+ .groupBy("批")
+ // 餈銵 蝏霈⊥
+ .count()
+ // 摰亥砭 撟嗉絲怠
+ .select(
+ FieldCell.$("批"),
+ FieldCell.$("count()").as("鈭箸")
+ )
+ );
+ }
+}
+```
+
+* Capable of functional update of row or column data for all values in DF data set objects, and supports conversion from
+ DF data objects to matrices.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+import zhao.algorithmMagic.operands.table.FieldCell;
+import zhao.algorithmMagic.operands.table.FinalCell;
+import zhao.algorithmMagic.operands.vector.IntegerVector;
+
+import java.io.File;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 憭隞嗅笆鞊
+ File file = new File("C:\\Users\\zhao\\Desktop\\out\\res1.csv");
+ // 雿輻 FDF 頧賣隞
+ DataFrame execute1 = FDataFrame.builder(file)
+ // 隞嗅笆鞊∠霂餃閬摰砍蝚
+ .setSep(',')
+ // 隞嗅笆鞊⊿閬摰憟賢蝘堆銝賭蝙 * 餈隞銵函銝舀亥砭嚗臬撱箔銝枋F摮畾
+ .create("id", "name", "sex")
+ // 隞嗅笆鞊∠銝駁格摰霈訾蝙典蝘
+ .primaryKey("name")
+ // 扯亥砭
+ .execute()
+ // 銝箏韏瑕怠
+ .select(
+ FieldCell.$("id"),
+ FieldCell.$("name").as("蝘"),
+ FieldCell.$("sex").as("批")
+ )
+ // 撠批怠餈銵頧祆g瑞銝1 憟喟銝0
+ .updateCol(FieldCell.$("批"), cell -> new FinalCell<>(cell.getStringValue().equals("") ? 1 : 0))
+ // 撠銵銝駁格啣潔蛹ZLY唳株銝剔潭踵X銝箸唳 405
+ .updateRow("ZLY", cell -> new FinalCell<>(405));
+
+ // 啣箄”銝剔銵銝駁桀蝘唬蛹 405 唳株
+ System.out.println(execute1.selectRow("405"));
+ long start = System.currentTimeMillis();
+ // 撠銵刻蓮X銝箔銝芣游耦拚萄笆鞊∴霂交雿隡撠DF撖寡情銝剔啣潸曇蓮X銝 col.count()*3 拚萄笆鞊
+ IntegerMatrix parse = IntegerMatrix.parse(execute1, execute1.count().getIntValue(), 3);
+ System.out.println(IntegerVector.parse(parse.getArrayByColIndex(2)));
+ System.out.print("憭塚MS嚗嚗");
+ System.out.println(System.currentTimeMillis() - start);
+ }
+}
+```
+
+* Support for obtaining image related data through a web URL object and converting it into an image matrix.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class MAIN1 {
+ public static void main(String[] args) throws MalformedURLException {
+ // 憭曉URL撖寡情
+ URL url = new URL("https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png");
+ // 閫URL瑕啣曉拚
+ ColorMatrix parse1 = ColorMatrix.parse(url);
+ // 閫URL瑕啣曉啣漲拚
+ ColorMatrix parse2 = ColorMatrix.parseGrayscale(url);
+ // 亦曉
+ parse1.show("image");
+ parse2.show("image");
+ }
+}
+```
+
+* It supports color binarization and regularization coverage, and can display more image features or remove more
+ redundant features by specifying the color values of the channel.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class MAIN1 {
+ public static void main(String[] args) throws MalformedURLException {
+ // 憭曉URL撖寡情
+ URL url = new URL("https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png");
+ // 閫URL瑕啣曉拚
+ ColorMatrix parse1 = ColorMatrix.parse(url);
+ // 撠 URL 曉拚萎葉 G 憸脫啣澆之鈭 40 憸脣港蛹暺莎銋港蛹質
+ // 刻曹拐 G 甇 蝏輯脰瘛 頞航賢銝箇質
+ parse1.globalBinary(ColorMatrix._G_, 40, 0, 0xffffff);
+ // 銋臭誑雿輻典嗅憸脤餈銵脣蔗靚
+ parse1.globalBinary(ColorMatrix._R_, 40, 0, 0xffffff);
+ parse1.globalBinary(ColorMatrix._B_, 40, 0, 0xffffff);
+ // 亦蝏曉
+ parse1.show("image");
+ }
+}
+```
+
+* Supports the construction of image ASCII images. You can quickly construct an image in ASCII, but please ensure that
+ the image size is small enough.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class MAIN1 {
+ public static void main(String[] args) throws MalformedURLException {
+ // 憭曉URL撖寡情
+ URL url = new URL("https://user-images.githubusercontent.com/113756063/194830221-abe24fcc-484b-4769-b3b7-ec6d8138f436.png");
+ // 閫URL瑕啣曉拚
+ ColorMatrix parse1 = ColorMatrix.parse(url);
+ // 亦蝏曉
+ parse1.show("image");
+ // 颲箏曉 ASCII 啣潘颲箄銝 G 憸脫啣 憭找 40 颲箇泵 'A' 嗅颲箇泵 ' '
+ parse1.save(
+ new File("C:\\Users\\zhao\\Desktop\\fsDownload\\res.txt"),
+ ColorMatrix._G_, 40, 'A', ' '
+ );
+ }
+}
+```
+
+* Ability to manually create an empty DataFrame object and independently manipulate the data therein.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+import zhao.algorithmMagic.operands.table.FieldCell;
+import zhao.algorithmMagic.operands.table.FinalSeries;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DF 撖寡情 隞 name 雿銝箄銝駁桃揣撘
+ FDataFrame create = FDataFrame.select(FieldCell.parse("name", "sex", "phoneNum"), 1);
+ // 乩鈭唳
+ DataFrame insert = create.insert(
+ FinalSeries.parse("zhao", "M", "110xxxxxxxx"),
+ FinalSeries.parse("tang", "W", "110xxxxxxxx"),
+ FinalSeries.parse("yang", "M", "110xxxxxxxx")
+ );
+ // 亦唳桅
+ System.out.println(insert);
+ // 撠嗡葉 name sex 亥砭
+ System.out.println(
+ insert.select(
+ FieldCell.$("name").as("AllName"),
+ FieldCell.$("sex").as("AllSex")
+ )
+ );
+ }
+}
+```
+
+* 舀 group 嗅摰 where摮伐雿踹霈∠憭批之憓撘
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+import zhao.algorithmMagic.operands.table.FieldCell;
+import zhao.algorithmMagic.operands.table.FinalSeries;
+
+import java.net.MalformedURLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DF 撖寡情 隞 name 雿銝箄銝駁桃揣撘
+ FDataFrame create = FDataFrame.select(FieldCell.parse("name", "sex", "phoneNum"), 1);
+ // 乩鈭唳
+ DataFrame insert = create.insert(
+ FinalSeries.parse("zhao1", "M", "110xxxxxxxx"),
+ FinalSeries.parse("tang2", "W", "120xxxxxxxx"),
+ FinalSeries.parse("yang3", "W", "110xxxxxxxx"),
+ FinalSeries.parse("zhao4", "M", "120xxxxxxxx"),
+ FinalSeries.parse("tang5", "W", "110xxxxxxxx"),
+ FinalSeries.parse("yang6", "W", "110xxxxxxxx"),
+ FinalSeries.parse("zhao7", "M", "120xxxxxxxx"),
+ FinalSeries.parse("tang8", "W", "110xxxxxxxx"),
+ FinalSeries.parse("yang9", "W", "110xxxxxxxx")
+ );
+ // 亦唳桅
+ System.out.println(insert);
+ // 撠嗡葉箏瑕銝雿銝銝 120 唳株批嗡葉 sex 蝏 刻湔乩蝙典蝏嗉皛文喳
+ System.out.println(
+ insert.groupBy("sex", v -> {
+ // 瑕唳箏瑞摮蝚虫葡
+ String s = v.getCell(2).toString();
+ // 斗剖 3 銝芸蝚行臬虫蛹 120 嚗臬虫誑 120 撘憭湛 憒臬停銝瘛餃
+ return !s.startsWith("120");
+ }).count()
+ );
+ }
+}
+```
+
+* Support for local binarization operations, which can effectively achieve image binarization processing. Compared to
+ global binarization, functions are more flexible.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class MAIN1 {
+ public static void main(String[] args) throws MalformedURLException {
+ // 瑕啣曉拚
+ ColorMatrix parse = ColorMatrix.parse(new URL("https://img-blog.csdnimg.cn/img_convert/5765bdab08ef6e117d434e7e225b9013.png"));
+ parse.show("image");
+ System.out.println("ok!!!");
+ System.out.println(" = " + parse.getRowCount());
+ System.out.println("摰 = " + parse.getColCount());
+ // 撠曉餈銵撅其澆
+ parse.localBinary(
+ // 摰祆活鈭澆拍憸脤
+ ColorMatrix._G_,
+ // 摰祆活鈭澆箇撅典曉拚菜圈
+ 100,
+ // 摰祆活鈭澆銝剖函拚萎葉憭找撅券潛憸脩
+ 0xffffff,
+ // 摰祆活鈭澆銝剖函拚萎葉撠鈭撅券潛憸脩
+ 0,
+ // 摰祆活鈭澆銝剖券潛閬餈銵敺株啣潘餈舫雿20銝芷潭啣
+ -30
+ );
+ // 亦蝏唳
+ parse.show("image");
+ }
+}
+```
+
+* DF object data supports saving as HTML files, enabling effective automated page rendering operations.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.DataFrame;
+import zhao.algorithmMagic.operands.table.FDataFrame;
+import zhao.algorithmMagic.operands.table.FieldCell;
+import zhao.algorithmMagic.operands.table.FinalSeries;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DF 撖寡情 隞 name 雿銝箄銝駁桃揣撘
+ FDataFrame create = FDataFrame.select(FieldCell.parse("name", "sex", "phoneNum", "salary"), 1);
+ // 乩鈭唳
+ DataFrame insert = create.insert(
+ FinalSeries.parse("zhao1", "M", "110xxxxxxxx", "30000"),
+ FinalSeries.parse("tang2", "W", "120xxxxxxxx", "30000"),
+ FinalSeries.parse("yang3", "W", "110xxxxxxxx", "30000"),
+ FinalSeries.parse("zhao4", "M", "120xxxxxxxx", "30000"),
+ FinalSeries.parse("tang5", "W", "110xxxxxxxx", "30000"),
+ FinalSeries.parse("yang6", "W", "110xxxxxxxx", "30000"),
+ FinalSeries.parse("zhao7", "M", "120xxxxxxxx", "30000"),
+ FinalSeries.parse("tang8", "W", "110xxxxxxxx", "30000"),
+ FinalSeries.parse("yang9", "W", "110xxxxxxxx", "30000")
+ );
+ // 颲箄”HTML 嗅亦銵其葉唳
+ System.out.println(
+ insert.into_outHtml("C:\\Users\\Liming\\Desktop\\fsDownload\\res11234.html", "myTable")
+ );
+ }
+}
+```
+
+* Images begin to support the add function, which enables overlapping and merging of image functions under the operation
+ of the add function!
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撠銝鈭曉隞嗉蓮X銝箔銝芸曉拚萄笆鞊
+ ColorMatrix colorMatrix1 = ColorMatrix.parse("C:\\Users\\Liming\\Desktop\\fsDownload\\test.bmp");
+ ColorMatrix colorMatrix2 = ColorMatrix.parse("C:\\Users\\Liming\\Desktop\\fsDownload\\test1.bmp");
+ // 撠 colorMatrix2 + colorMatrix1 蝏曉撅蝷箏箸
+ (colorMatrix1.add(colorMatrix2)).show("image");
+ }
+}
+```
+
+* Support aggregation operations for custom aggregation and built-in data schemes.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撠銝鈭曉隞嗉蓮X銝箔銝芸曉拚萄笆鞊
+ ColorMatrix colorMatrix1 = ColorMatrix.parse("C:\\Users\\Liming\\Desktop\\fsDownload\\test.bmp");
+ ColorMatrix colorMatrix2 = ColorMatrix.parse("C:\\Users\\Liming\\Desktop\\fsDownload\\test1.bmp");
+ // 雿輻 agg 賣唬誑蝵桃霈∠寞餈銵銝支葵拚萇撟
+ // 銝W賣唬葉蝚砌銝芸耦隞銵函撠望舐拚萎葉蝝餉嚗餈雿輻函舀嚗撟嗅笆頞憸脫啣潸銵閫渡餉摰
+ colorMatrix1.agg(colorMatrix2, ColorMatrix.COLOR_SUM_REGULATE).show("image");
+ }
+}
+```
+
+* The image matrix supports a corrosion operation function in which redundant feature data can be removed.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.matrix.ColorMatrix;
+
+import java.sql.SQLException;
+
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撠銝鈭曉隞嗉蓮X銝箔銝芸曉拚萄笆鞊
+ ColorMatrix colorMatrix1 = ColorMatrix.parseGrayscale("C:\\Users\\Liming\\Desktop\\fsDownload\\test2.bmp");
+ // 撖孵曉餈銵鈭澆
+ colorMatrix1.globalBinary(ColorMatrix._G_, 100, 0xffffff, 0);
+ colorMatrix1.show("銋 image");
+ // 撘憪撖孵曉拚菔銵雿
+ colorMatrix1.erode(2, 2, false).show("銋 image");
+ }
+}
+```
+
+* The addition of columns is supported, but it should be noted that the addition of columns will return a new DataFrame
+ DF in which the data will be lightly copied.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.*;
+
+import java.sql.SQLException;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DataFrame 撖寡情
+ FDataFrame select = FDataFrame.select(
+ FieldCell.parse("id", "name", "sex", "age"), 1
+ );
+ // 冽交唳
+ select.insert(
+ FinalSeries.parse("1", "zhao", "M", "19"),
+ FinalSeries.parse("2", "tang", "W", "18"),
+ FinalSeries.parse("3", "yang", "W", "20"),
+ FinalSeries.parse("4", "shen", "W", "19")
+ );
+ // 啣 DF 撖寡情喟靽⊥
+ System.out.println(
+ select.desc()
+ );
+ // 瘛餃銝唳殷其銵函內撟湧臬虫蛹嗆
+ DataFrame ageIsE = select.insertColGetNew(
+ // 啣蝘
+ FieldCell.$("AgeIsE"),
+ // 啣啣潛餉 憒蝚 4 嚗index == 3嚗啣 % 2 == 0 撠望眩rue
+ cells -> cells.getCell(3).getIntValue() % 2 == 0 ? new FinalCell<>(true) : new FinalCell<>(false)
+ );
+ System.out.println(ageIsE);
+ }
+}
+```
+
+* Supports operations between table data, and can perform summation and subtraction calculations on all numeric types in
+ the table. After calculation, a new DF object will be returned.
+
+```java
+package zhao.algorithmMagic;
+
+import zhao.algorithmMagic.operands.table.*;
+
+public class MAIN1 {
+ public static void main(String[] args) {
+ // 撱箔銝芰征 DataFrame 撖寡情
+ FDataFrame select1 = FDataFrame.select(
+ FieldCell.parse("id", "name", "sex", "age"), 1
+ );
+ // 冽交唳
+ select1.insert(
+ FinalSeries.parse("1", "zhao", "M", "19"),
+ FinalSeries.parse("2", "tang", "W", "18"),
+ FinalSeries.parse("3", "yang", "W", "20"),
+ FinalSeries.parse("4", "shen", "W", "19")
+ );
+ // 撱箔銝芰征 DataFrame 撖寡情
+ FDataFrame select2 = FDataFrame.select(
+ FieldCell.parse("id", "name", "sex", "age"), 1
+ );
+ // 冽交唳
+ select2.insert(
+ FinalSeries.parse("1", "zhao", "M", "19"),
+ FinalSeries.parse("2", "tang", "W", "18"),
+ FinalSeries.parse("3", "yang", "W", "20")
+ );
+ // 餈銵瘙銝撌桃餈蝞雿
+ System.out.println(select1.add(select2));
+ System.out.println(select1.diff(select2));
+ }
+}
+```
+
+* Note for the new version: All dependencies in this version are marked as provided, which can minimize redundancy and
+ enable related configuration based on your actual project. Therefore, when performing AS library injection, please
+ import the following required items in one click.
+
+```xml
+
+
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ 2.20.0
+
+
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.20.0
+
+
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.20.0
+
+
+
+```
+
+### Version update date : 2023-03-26
\ No newline at end of file
| | | | | |