use of com.tencent.angel.ml.math2.utils.UnionEle in project angel by Tencent.
the class CompReduceExecutor method apply.
private static UnionEle apply(CompIntIntVector v, ReduceOP op, int start, int end) {
UnionEle res = new UnionEle();
IntIntVector[] parts = v.getPartitions();
switch(op) {
case Sum:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
}
break;
case Avg:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
res.setLong1(res.getLong1() + parts[i].getDim());
}
break;
case Std:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
double norm = parts[i].norm();
res.setDouble2(res.getDouble2() + norm * norm);
res.setLong1(res.getLong1() + parts[i].getDim());
}
break;
case Norm:
for (int i = start; i <= end; i++) {
double norm = parts[i].norm();
res.setDouble2(res.getDouble2() + norm * norm);
}
break;
case Min:
res.setDouble1(Double.MAX_VALUE);
for (int i = start; i <= end; i++) {
res.setDouble1(Math.min(res.getDouble1(), parts[i].min()));
}
break;
case Max:
res.setDouble1(Double.MIN_VALUE);
for (int i = start; i <= end; i++) {
res.setDouble1(Math.max(res.getDouble1(), parts[i].max()));
}
break;
case Size:
for (int i = start; i <= end; i++) {
res.setLong1(res.getLong1() + parts[i].size());
}
break;
case Numzeros:
for (int i = start; i <= end; i++) {
res.setLong1(res.getLong1() + parts[i].numZeros());
}
break;
}
return res;
}
use of com.tencent.angel.ml.math2.utils.UnionEle in project angel by Tencent.
the class CompReduceExecutor method apply.
private static UnionEle apply(CompLongDoubleVector v, ReduceOP op, int start, int end) {
UnionEle res = new UnionEle();
LongDoubleVector[] parts = v.getPartitions();
switch(op) {
case Sum:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
}
break;
case Avg:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
res.setLong1(res.getLong1() + parts[i].getDim());
}
break;
case Std:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
double norm = parts[i].norm();
res.setDouble2(res.getDouble2() + norm * norm);
res.setLong1(res.getLong1() + parts[i].getDim());
}
break;
case Norm:
for (int i = start; i <= end; i++) {
double norm = parts[i].norm();
res.setDouble2(res.getDouble2() + norm * norm);
}
break;
case Min:
res.setDouble1(Double.MAX_VALUE);
for (int i = start; i <= end; i++) {
res.setDouble1(Math.min(res.getDouble1(), parts[i].min()));
}
break;
case Max:
res.setDouble1(Double.MIN_VALUE);
for (int i = start; i <= end; i++) {
res.setDouble1(Math.max(res.getDouble1(), parts[i].max()));
}
break;
case Size:
for (int i = start; i <= end; i++) {
res.setLong1(res.getLong1() + parts[i].size());
}
break;
case Numzeros:
for (int i = start; i <= end; i++) {
res.setLong1(res.getLong1() + parts[i].numZeros());
}
break;
}
return res;
}
use of com.tencent.angel.ml.math2.utils.UnionEle in project angel by Tencent.
the class CompReduceExecutor method apply.
private static UnionEle apply(CompLongFloatVector v, ReduceOP op, int start, int end) {
UnionEle res = new UnionEle();
LongFloatVector[] parts = v.getPartitions();
switch(op) {
case Sum:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
}
break;
case Avg:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
res.setLong1(res.getLong1() + parts[i].getDim());
}
break;
case Std:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
double norm = parts[i].norm();
res.setDouble2(res.getDouble2() + norm * norm);
res.setLong1(res.getLong1() + parts[i].getDim());
}
break;
case Norm:
for (int i = start; i <= end; i++) {
double norm = parts[i].norm();
res.setDouble2(res.getDouble2() + norm * norm);
}
break;
case Min:
res.setDouble1(Double.MAX_VALUE);
for (int i = start; i <= end; i++) {
res.setDouble1(Math.min(res.getDouble1(), parts[i].min()));
}
break;
case Max:
res.setDouble1(Double.MIN_VALUE);
for (int i = start; i <= end; i++) {
res.setDouble1(Math.max(res.getDouble1(), parts[i].max()));
}
break;
case Size:
for (int i = start; i <= end; i++) {
res.setLong1(res.getLong1() + parts[i].size());
}
break;
case Numzeros:
for (int i = start; i <= end; i++) {
res.setLong1(res.getLong1() + parts[i].numZeros());
}
break;
}
return res;
}
use of com.tencent.angel.ml.math2.utils.UnionEle in project angel by Tencent.
the class CompReduceExecutor method apply.
private static UnionEle apply(CompIntDoubleVector v, ReduceOP op, int start, int end) {
UnionEle res = new UnionEle();
IntDoubleVector[] parts = v.getPartitions();
switch(op) {
case Sum:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
}
break;
case Avg:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
res.setLong1(res.getLong1() + parts[i].getDim());
}
break;
case Std:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
double norm = parts[i].norm();
res.setDouble2(res.getDouble2() + norm * norm);
res.setLong1(res.getLong1() + parts[i].getDim());
}
break;
case Norm:
for (int i = start; i <= end; i++) {
double norm = parts[i].norm();
res.setDouble2(res.getDouble2() + norm * norm);
}
break;
case Min:
res.setDouble1(Double.MAX_VALUE);
for (int i = start; i <= end; i++) {
res.setDouble1(Math.min(res.getDouble1(), parts[i].min()));
}
break;
case Max:
res.setDouble1(Double.MIN_VALUE);
for (int i = start; i <= end; i++) {
res.setDouble1(Math.max(res.getDouble1(), parts[i].max()));
}
break;
case Size:
for (int i = start; i <= end; i++) {
res.setLong1(res.getLong1() + parts[i].size());
}
break;
case Numzeros:
for (int i = start; i <= end; i++) {
res.setLong1(res.getLong1() + parts[i].numZeros());
}
break;
}
return res;
}
use of com.tencent.angel.ml.math2.utils.UnionEle in project angel by Tencent.
the class CompReduceExecutor method apply.
private static UnionEle apply(CompIntLongVector v, ReduceOP op, int start, int end) {
UnionEle res = new UnionEle();
IntLongVector[] parts = v.getPartitions();
switch(op) {
case Sum:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
}
break;
case Avg:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
res.setLong1(res.getLong1() + parts[i].getDim());
}
break;
case Std:
for (int i = start; i <= end; i++) {
res.setDouble1(res.getDouble1() + parts[i].sum());
double norm = parts[i].norm();
res.setDouble2(res.getDouble2() + norm * norm);
res.setLong1(res.getLong1() + parts[i].getDim());
}
break;
case Norm:
for (int i = start; i <= end; i++) {
double norm = parts[i].norm();
res.setDouble2(res.getDouble2() + norm * norm);
}
break;
case Min:
res.setDouble1(Double.MAX_VALUE);
for (int i = start; i <= end; i++) {
res.setDouble1(Math.min(res.getDouble1(), parts[i].min()));
}
break;
case Max:
res.setDouble1(Double.MIN_VALUE);
for (int i = start; i <= end; i++) {
res.setDouble1(Math.max(res.getDouble1(), parts[i].max()));
}
break;
case Size:
for (int i = start; i <= end; i++) {
res.setLong1(res.getLong1() + parts[i].size());
}
break;
case Numzeros:
for (int i = start; i <= end; i++) {
res.setLong1(res.getLong1() + parts[i].numZeros());
}
break;
}
return res;
}
Aggregations