Skip to content

Commit d4f2792

Browse files
1.30版本发布 (#19)
* update * update * update * update * update * update * update * update * update * 1.26版本发布 * 1.27 版本发布 * update * 1.28 版本发布 * Update README.md * 修复向量不能自动刷新的问题 * 1.29 版本发布 * 帮助信息的获取使用备份链接 在 1.30 版本中会启用此链接 * 1.3.0版本开始开发 * update * 1.30版本发布
1 parent 6a62111 commit d4f2792

26 files changed

+1462
-147
lines changed

AsLib/LibSrc/.idea/workspace.xml

Lines changed: 8 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Start testing: Jan 03 17:07 ?D1��������?����??
1+
Start testing: Jan 30 20:48 ?D1��������?����??
22
----------------------------------------------------------
3-
End testing: Jan 03 17:07 ?D1��������?����??
3+
End testing: Jan 30 20:48 ?D1��������?����??

AsLib/libBeardedManZhao.dll

0 Bytes
Binary file not shown.

README-Chinese.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AS库目录有多个版本,如果希望查询不同版本的更新日志以及
2323
<dependency>
2424
<groupId>io.github.BeardedManZhao</groupId>
2525
<artifactId>algorithmStar</artifactId>
26-
<version>1.29</version>
26+
<version>1.30</version>
2727
</dependency>
2828
</dependencies>
2929
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ can add it to your maven project, or you can download it from Releases and manua
2929
<dependency>
3030
<groupId>io.github.BeardedManZhao</groupId>
3131
<artifactId>algorithmStar</artifactId>
32-
<version>1.29</version>
32+
<version>1.30</version>
3333
</dependency>
3434
</dependencies>
3535
```

src_code/README-Chinese.md

Lines changed: 118 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,96 +8,152 @@
88

99
### 更新日志
1010

11-
* 框架版本:1.28 - 1.29
12-
* 修正矩阵工厂类的名字
11+
* 框架版本:1.29 - 1.30
12+
* 新增单位数值类操作数,此操作数可以实现基本计算,同时还可以实现带有单位的计算效果,其还具有单位转换操作,且允许自定义单位!!!
13+
* 内置了 BaseValue 类,其可以实现加减乘除运算,同时还支持单位数值的转换,可以直接使用
1314

1415
```java
15-
public class MAIN1 {
16-
public static void main(String[] args) {
17-
final MatrixFactory matrixFactory = AlgorithmStar.matrixFactory();
18-
}
19-
}
20-
```
21-
22-
* 修复在进行向量中的不拷贝反转操作时,打印出来的数据不正确问题,这是由于向量内部的数据没有自动刷新,1.29 版本已解决此问题!
23-
24-
```java
25-
package com.zhao;
16+
package zhao.algorithmMagic;
2617

2718
import zhao.algorithmMagic.core.AlgorithmStar;
28-
import zhao.algorithmMagic.core.VectorFactory;
29-
import zhao.algorithmMagic.operands.vector.IntegerVector;
19+
import zhao.algorithmMagic.core.BaseValueFactory;
20+
import zhao.algorithmMagic.operands.unit.BaseValue;
3021

31-
public class MAIN {
22+
import java.net.MalformedURLException;
23+
24+
public class MAIN1 {
3225
public static void main(String[] args) {
33-
// 创建向量对象
34-
final VectorFactory vectorFactory = AlgorithmStar.vectorFactory();
35-
final IntegerVector integerVector = vectorFactory.parseVector(1, 2, 43, 4);
36-
// 向量整体反转 这里的参数代表的就是是否需要在拷贝的新向量中进行转换 1.28 以及 1.28 之前的版本
37-
// 打印出的字符串不太正确 1.29版本中会修复此问题
38-
System.out.println(integerVector.reverseLR(false));
26+
// 构建一个用来创建 BaseValue.class 的工厂类 TODO 这里的类型可以是其它的 但是要确保是 BaseValue 的子类
27+
final BaseValueFactory baseValueFactory = AlgorithmStar.baseValueFactory(BaseValue.class);
28+
// 获取到数值
29+
final BaseValue number_1 = baseValueFactory.parse(200);
30+
System.out.println("number_1 = " + number_1);
31+
final BaseValue number_2 = baseValueFactory.parse(1024);
32+
System.out.println("number_2 = " + number_2);
33+
34+
// 基本的运算演示
35+
System.out.println("============");
36+
System.out.println(number_2 + " + " + number_1 + " = " + number_1.add(number_2));
37+
System.out.println(number_2 + " + " + 2 + number_2.getNowBase().getValue() + " = " + number_2.add(2));
38+
39+
System.out.println("============");
40+
System.out.println(number_2 + " - " + number_1 + " = " + number_1.diff(number_2));
41+
System.out.println(number_2 + " - " + 2 + number_2.getNowBase().getValue() + " = " + number_2.diff(2));
42+
43+
System.out.println("============");
44+
System.out.println(number_2 + " * " + number_1 + " = " + number_1.multiply(number_2));
45+
System.out.println(number_2 + " * " + 2 + number_2.getNowBase().getValue() + " = " + number_2.multiply(2));
46+
47+
System.out.println("============");
48+
System.out.println(number_2 + " / " + number_1 + " = " + number_1.divide(number_2));
49+
System.out.println(number_2 + " / " + 2 + number_2.getNowBase().getValue() + " = " + number_2.divide(2));
50+
51+
// 将 1.024千 转换为 10.24百 和 0.1024 万
52+
System.out.println("============");
53+
System.out.println(number_2.switchUnits(""));
54+
System.out.println(number_2.switchUnits(""));
3955
}
4056
}
57+
4158
```
4259

43-
* 针对矩阵工厂,增加了一些创建方式,您可以直接通过工厂类中进行稀疏矩阵的解析,当然,这个操作在1.29之前的版本中也是支持的!!!
60+
* 如果需要自定义单位,可以直接继承 BaseValue 类,然后标注 BaseUnit 注解即可,下面是一个基本的实例(下面的类也已经加入到了AS库)
61+
* 继承 BaseValue 并重写静态的 parse 函数
62+
* 标注 BaseUnit 注解 在其中设置单位 与 进制值
4463

4564
```java
46-
package zhao.algorithmMagic;
65+
package zhao.algorithmMagic.operands.unit;
66+
67+
import zhao.algorithmMagic.utils.dataContainer.KeyValue;
68+
69+
/**
70+
* 重量单位数值,在这里可以直接使用重量相关的单位!
71+
*
72+
* Weight unit value, weight related units can be directly used here!
73+
* @author zhao
74+
*/
75+
@BaseUnit(value = {
76+
"t(吨)", "kg(千克)", "g(克)", "mg(毫克)", "ug(微克)", "ng(纳克)", "pg(皮克)", "fg(飞克)"
77+
}, baseValue = 1000)
78+
public class WeightValue extends BaseValue {
79+
80+
protected WeightValue(double valueNumber, Class<? extends BaseValue> c, KeyValue<Integer, String> baseNameKeyValue) {
81+
super(valueNumber, c, baseNameKeyValue);
82+
}
4783

48-
import zhao.algorithmMagic.core.AlgorithmStar;
49-
import zhao.algorithmMagic.core.MatrixFactory;
50-
import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
51-
import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
84+
/**
85+
* @param valueNumber 需要被解析的数值
86+
* <p>
87+
* Value that needs to be parsed
88+
* @return 解析之后的单位数值对象
89+
* <p>
90+
* Parsed Unit Value Object
91+
*/
92+
public static BaseValue parse(double valueNumber) {
93+
return parse(valueNumber, null);
94+
}
5295

53-
public class MAIN1 {
54-
public static void main(String[] args) {
55-
final MatrixFactory matrixFactory = AlgorithmStar.matrixFactory();
56-
// 通过 工厂类 以及稀疏矩阵的方式创建两个矩阵
57-
final IntegerMatrix integerMatrix = matrixFactory.sparseMatrix(
58-
// 在坐标 (2,3) 的位置创建一个元素 1
59-
new int[]{1, 2, 3},
60-
// 在坐标 (1,2) 的位置创建一个元素 2
61-
new int[]{2, 1, 2}
62-
);
63-
final DoubleMatrix doubleMatrix = matrixFactory.sparseMatrix(
64-
// 在坐标 (2,3) 的位置创建一个元素 1
65-
new double[]{1, 2, 3},
66-
// 在坐标 (1,2) 的位置创建一个元素 2
67-
new double[]{2, 1, 2}
68-
);
69-
System.out.println(integerMatrix);
70-
System.out.println(doubleMatrix);
96+
/**
97+
* @param valueNumber 需要被解析的数值
98+
* <p>
99+
* Value that needs to be parsed
100+
* @param baseNameKeyValue 单位的键值对,如果您需要指定数值的单位,您可以在这里进行指定,如果您不需要可以直接设置为 null,请注意 如果您不设置为null 此操作将不会对数值进行任何化简.
101+
* <p>
102+
* The key value pairs of units. If you need to specify the unit of a numerical value, you can specify it here. If you don't need it, you can directly set it to null. Please note that if you don't set it to null, this operation will not simplify the numerical value in any way.
103+
* @return 解析之后的单位数值对象
104+
* <p>
105+
* Parsed Unit Value Object
106+
*/
107+
protected static BaseValue parse(double valueNumber, KeyValue<Integer, String> baseNameKeyValue) {
108+
return new BaseValue(valueNumber, WeightValue.class, baseNameKeyValue);
71109
}
72110
}
111+
73112
```
74113

75-
* 您也可以使用矩阵工厂来进行一个矩阵的填充和随机创建
114+
然后就可以进行使用啦
76115

77116
```java
78117
package zhao.algorithmMagic;
79118

80119
import zhao.algorithmMagic.core.AlgorithmStar;
81-
import zhao.algorithmMagic.core.MatrixFactory;
82-
import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
83-
import zhao.algorithmMagic.operands.matrix.IntegerMatrix;
120+
import zhao.algorithmMagic.core.BaseValueFactory;
121+
import zhao.algorithmMagic.operands.unit.BaseValue;
122+
import zhao.algorithmMagic.operands.unit.WeightValue;
123+
124+
import java.net.MalformedURLException;
84125

85126
public class MAIN1 {
86127
public static void main(String[] args) {
87-
final MatrixFactory matrixFactory = AlgorithmStar.matrixFactory();
88-
// 通过 工厂类 以及稀疏矩阵的方式创建两个矩阵 4行5列 元素全是 2
89-
final IntegerMatrix integerMatrix = matrixFactory.fill(2, 4, 5);
90-
final DoubleMatrix doubleMatrix = matrixFactory.fill(2.0, 4, 5);
91-
System.out.println(integerMatrix);
92-
System.out.println(doubleMatrix);
93-
// 使用随机的方式创建矩阵
94-
final IntegerMatrix integerMatrix1 = matrixFactory.randomGetInt(4, 5, 100);
95-
final DoubleMatrix doubleMatrix1 = matrixFactory.randomGetDouble(4, 5, 100);
96-
System.out.println(integerMatrix1);
97-
System.out.println(doubleMatrix1);
128+
// 构建一个用来创建 WeightValue.class 的工厂类 TODO 这里的类型可以是其它的 但是要确保是 BaseValue 的子类
129+
final BaseValueFactory baseValueFactory = AlgorithmStar.baseValueFactory(WeightValue.class);
130+
// 获取到数值
131+
final BaseValue number_1 = baseValueFactory.parse(200);
132+
System.out.println("number_1 = " + number_1);
133+
// 将第一个的单位转换为 克
134+
number_1.switchUnitsNotChange("g(克)");
135+
System.out.println("number_1 = " + number_1);
136+
// 获取到第二个数值
137+
final BaseValue number_2 = baseValueFactory.parse(102.4);
138+
// 将第二个转换为 毫克
139+
number_2.switchUnitsNotChange("mg(毫克)");
140+
System.out.println("number_2 = " + number_2);
141+
// 进行一个计算
142+
System.out.println("number_1 + number_2 = " + number_1.add(number_2));
98143
}
99144
}
100145

101146
```
102147

103-
### Version update date : 2024-01-13
148+
* 内置的单位数值类
149+
150+
| 类路径 | 名称 | 加入版本 | 支持计算 |
151+
|-----------------------------------------------|---------|-------|------|
152+
| zhao.algorithmMagic.operands.unit.BaseValue | 基础单位数值类 | v1.30 | yes |
153+
| zhao.algorithmMagic.operands.unit.DataValue | 数据单位数值类 | v1.30 | yes |
154+
| zhao.algorithmMagic.operands.unit.VolumeValue | 容量单位数值类 | v1.30 | yes |
155+
| zhao.algorithmMagic.operands.unit.WeightValue | 重量单位数值类 | v1.30 | yes |
156+
| zhao.algorithmMagic.operands.unit.DateValue | 时间单位数值类 | v1.30 | yes |
157+
158+
159+
### Version update date : 2024-01-30

0 commit comments

Comments
 (0)