use of com.tencent.angel.ml.math2.vector.IntLongVector in project angel by Tencent.
the class BinaryMatrixExecutor method apply.
private static Matrix apply(BlasFloatMatrix mat, IntLongVector v, int idx, boolean onCol, Binary op) {
float[] data = mat.getData();
int m = mat.getNumRows(), n = mat.getNumCols();
int size = v.size();
byte[] flag = null;
if (!v.isDense()) {
flag = new byte[v.getDim()];
}
if (onCol && op.isInplace()) {
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int i = 0; i < m; i++) {
data[i * n + idx] = op.apply(data[i * n + idx], values[i]);
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int i = entry.getIntKey();
flag[i] = 1;
data[i * n + idx] = op.apply(data[i * n + idx], entry.getLongValue());
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int i = idxs[k];
flag[i] = 1;
data[i * n + idx] = op.apply(data[i * n + idx], values[k]);
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
data[i * n + idx] = 0;
}
}
case UNION:
break;
case ALL:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
data[i * n + idx] = op.apply(data[i * n + idx], 0);
}
}
}
}
return mat;
} else if (onCol && !op.isInplace()) {
float[] newData;
if (op.getOpType() == INTERSECTION) {
newData = new float[m * n];
} else {
newData = ArrayCopy.copy(data);
}
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int i = 0; i < m; i++) {
newData[i * n + idx] = op.apply(data[i * n + idx], values[i]);
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int i = entry.getIntKey();
flag[i] = 1;
newData[i * n + idx] = op.apply(data[i * n + idx], entry.getLongValue());
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int i = idxs[k];
flag[i] = 1;
newData[i * n + idx] = op.apply(data[i * n + idx], values[k]);
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
break;
case UNION:
break;
case ALL:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
newData[i * n + idx] = op.apply(data[i * n + idx], 0);
}
}
}
}
return new BlasFloatMatrix(mat.getMatrixId(), mat.getClock(), m, n, newData);
} else if (!onCol && op.isInplace()) {
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int j = 0; j < n; j++) {
data[idx * n + j] = op.apply(data[idx * n + j], values[j]);
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int j = entry.getIntKey();
flag[j] = 1;
data[idx * n + j] = op.apply(data[idx * n + j], entry.getLongValue());
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int j = idxs[k];
flag[j] = 1;
data[idx * n + j] = op.apply(data[idx * n + j], values[k]);
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
data[idx * n + j] = 0;
}
}
case UNION:
break;
case ALL:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
data[idx * n + j] = op.apply(data[idx * n + j], 0);
}
}
}
}
return mat;
} else {
float[] newData;
if (op.getOpType() == INTERSECTION) {
newData = new float[m * n];
} else {
newData = ArrayCopy.copy(data);
}
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int j = 0; j < n; j++) {
newData[idx * n + j] = op.apply(data[idx * n + j], values[j]);
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int j = entry.getIntKey();
flag[j] = 1;
newData[idx * n + j] = op.apply(data[idx * n + j], entry.getLongValue());
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int j = idxs[k];
flag[j] = 1;
newData[idx * n + j] = op.apply(data[idx * n + j], values[k]);
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
break;
case UNION:
break;
case ALL:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
newData[idx * n + j] = op.apply(data[idx * n + j], 0);
}
}
}
}
return new BlasFloatMatrix(mat.getMatrixId(), mat.getClock(), m, n, newData);
}
}
use of com.tencent.angel.ml.math2.vector.IntLongVector in project angel by Tencent.
the class BinaryMatrixExecutor method apply.
private static Matrix apply(BlasDoubleMatrix mat, IntLongVector v, boolean onCol, Binary op) {
double[] data = mat.getData();
int m = mat.getNumRows(), n = mat.getNumCols();
int size = v.size();
byte[] flag = null;
if (!v.isDense()) {
flag = new byte[v.getDim()];
}
if (onCol && op.isInplace()) {
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int i = 0; i < m; i++) {
long value = values[i];
for (int j = 0; j < n; j++) {
data[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int i = entry.getIntKey();
flag[i] = 1;
double value = entry.getLongValue();
for (int j = 0; j < n; j++) {
data[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int i = idxs[k];
flag[i] = 1;
long value = values[k];
for (int j = 0; j < n; j++) {
data[i * n + j] = op.apply(data[i * n + j], value);
}
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
for (int j = 0; j < n; j++) {
data[i * n + j] = 0;
}
}
}
case UNION:
break;
case ALL:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
for (int j = 0; j < n; j++) {
data[i * n + j] = op.apply(data[i * n + j], 0);
}
}
}
}
}
return mat;
} else if (onCol && !op.isInplace()) {
double[] newData;
if (op.getOpType() == INTERSECTION) {
newData = new double[m * n];
} else {
newData = ArrayCopy.copy(data);
}
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int i = 0; i < m; i++) {
long value = values[i];
for (int j = 0; j < n; j++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int i = entry.getIntKey();
flag[i] = 1;
double value = entry.getLongValue();
for (int j = 0; j < n; j++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int i = idxs[k];
flag[i] = 1;
long value = values[k];
for (int j = 0; j < n; j++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
break;
case UNION:
break;
case ALL:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
for (int j = 0; j < n; j++) {
newData[i * n + j] = op.apply(data[i * n + j], 0);
}
}
}
}
}
return new BlasDoubleMatrix(mat.getMatrixId(), mat.getClock(), m, n, newData);
} else if (!onCol && op.isInplace()) {
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
data[i * n + j] = op.apply(data[i * n + j], values[j]);
}
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int j = entry.getIntKey();
double value = entry.getLongValue();
flag[j] = 1;
for (int i = 0; i < m; i++) {
data[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int j = idxs[k];
long value = values[k];
flag[j] = 1;
for (int i = 0; i < m; i++) {
data[i * n + j] = op.apply(data[i * n + j], value);
}
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
for (int i = 0; i < m; i++) {
data[i * n + j] = 0;
}
}
}
case UNION:
break;
case ALL:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
for (int i = 0; i < m; i++) {
data[i * n + j] = op.apply(data[i * n + j], 0);
}
}
}
}
}
return mat;
} else {
double[] newData;
if (op.getOpType() == INTERSECTION) {
newData = new double[m * n];
} else {
newData = ArrayCopy.copy(data);
}
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int j = 0; j < n; j++) {
long value = values[j];
for (int i = 0; i < m; i++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int j = entry.getIntKey();
flag[j] = 1;
double value = entry.getLongValue();
for (int i = 0; i < m; i++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int j = idxs[k];
flag[j] = 1;
long value = values[k];
for (int i = 0; i < m; i++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
break;
case UNION:
break;
case ALL:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
for (int i = 0; i < m; i++) {
newData[i * n + j] = op.apply(data[i * n + j], 0);
}
}
}
}
}
return new BlasDoubleMatrix(mat.getMatrixId(), mat.getClock(), m, n, newData);
}
}
use of com.tencent.angel.ml.math2.vector.IntLongVector in project angel by Tencent.
the class BinaryMatrixExecutor method apply.
private static Matrix apply(BlasFloatMatrix mat, IntLongVector v, boolean onCol, Binary op) {
float[] data = mat.getData();
int m = mat.getNumRows(), n = mat.getNumCols();
int size = v.size();
byte[] flag = null;
if (!v.isDense()) {
flag = new byte[v.getDim()];
}
if (onCol && op.isInplace()) {
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int i = 0; i < m; i++) {
long value = values[i];
for (int j = 0; j < n; j++) {
data[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int i = entry.getIntKey();
flag[i] = 1;
float value = entry.getLongValue();
for (int j = 0; j < n; j++) {
data[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int i = idxs[k];
flag[i] = 1;
long value = values[k];
for (int j = 0; j < n; j++) {
data[i * n + j] = op.apply(data[i * n + j], value);
}
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
for (int j = 0; j < n; j++) {
data[i * n + j] = 0;
}
}
}
case UNION:
break;
case ALL:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
for (int j = 0; j < n; j++) {
data[i * n + j] = op.apply(data[i * n + j], 0);
}
}
}
}
}
return mat;
} else if (onCol && !op.isInplace()) {
float[] newData;
if (op.getOpType() == INTERSECTION) {
newData = new float[m * n];
} else {
newData = ArrayCopy.copy(data);
}
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int i = 0; i < m; i++) {
long value = values[i];
for (int j = 0; j < n; j++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int i = entry.getIntKey();
flag[i] = 1;
float value = entry.getLongValue();
for (int j = 0; j < n; j++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int i = idxs[k];
flag[i] = 1;
long value = values[k];
for (int j = 0; j < n; j++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
break;
case UNION:
break;
case ALL:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
for (int j = 0; j < n; j++) {
newData[i * n + j] = op.apply(data[i * n + j], 0);
}
}
}
}
}
return new BlasFloatMatrix(mat.getMatrixId(), mat.getClock(), m, n, newData);
} else if (!onCol && op.isInplace()) {
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
data[i * n + j] = op.apply(data[i * n + j], values[j]);
}
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int j = entry.getIntKey();
float value = entry.getLongValue();
flag[j] = 1;
for (int i = 0; i < m; i++) {
data[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int j = idxs[k];
long value = values[k];
flag[j] = 1;
for (int i = 0; i < m; i++) {
data[i * n + j] = op.apply(data[i * n + j], value);
}
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
for (int i = 0; i < m; i++) {
data[i * n + j] = 0;
}
}
}
case UNION:
break;
case ALL:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
for (int i = 0; i < m; i++) {
data[i * n + j] = op.apply(data[i * n + j], 0);
}
}
}
}
}
return mat;
} else {
float[] newData;
if (op.getOpType() == INTERSECTION) {
newData = new float[m * n];
} else {
newData = ArrayCopy.copy(data);
}
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int j = 0; j < n; j++) {
long value = values[j];
for (int i = 0; i < m; i++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int j = entry.getIntKey();
flag[j] = 1;
float value = entry.getLongValue();
for (int i = 0; i < m; i++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int j = idxs[k];
flag[j] = 1;
long value = values[k];
for (int i = 0; i < m; i++) {
newData[i * n + j] = op.apply(data[i * n + j], value);
}
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
break;
case UNION:
break;
case ALL:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
for (int i = 0; i < m; i++) {
newData[i * n + j] = op.apply(data[i * n + j], 0);
}
}
}
}
}
return new BlasFloatMatrix(mat.getMatrixId(), mat.getClock(), m, n, newData);
}
}
use of com.tencent.angel.ml.math2.vector.IntLongVector in project angel by Tencent.
the class BinaryMatrixExecutor method apply.
private static Matrix apply(BlasDoubleMatrix mat, IntLongVector v, int idx, boolean onCol, Binary op) {
double[] data = mat.getData();
int m = mat.getNumRows(), n = mat.getNumCols();
int size = v.size();
byte[] flag = null;
if (!v.isDense()) {
flag = new byte[v.getDim()];
}
if (onCol && op.isInplace()) {
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int i = 0; i < m; i++) {
data[i * n + idx] = op.apply(data[i * n + idx], values[i]);
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int i = entry.getIntKey();
flag[i] = 1;
data[i * n + idx] = op.apply(data[i * n + idx], entry.getLongValue());
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int i = idxs[k];
flag[i] = 1;
data[i * n + idx] = op.apply(data[i * n + idx], values[k]);
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
data[i * n + idx] = 0;
}
}
case UNION:
break;
case ALL:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
data[i * n + idx] = op.apply(data[i * n + idx], 0);
}
}
}
}
return mat;
} else if (onCol && !op.isInplace()) {
double[] newData;
if (op.getOpType() == INTERSECTION) {
newData = new double[m * n];
} else {
newData = ArrayCopy.copy(data);
}
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int i = 0; i < m; i++) {
newData[i * n + idx] = op.apply(data[i * n + idx], values[i]);
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int i = entry.getIntKey();
flag[i] = 1;
newData[i * n + idx] = op.apply(data[i * n + idx], entry.getLongValue());
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int i = idxs[k];
flag[i] = 1;
newData[i * n + idx] = op.apply(data[i * n + idx], values[k]);
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
break;
case UNION:
break;
case ALL:
for (int i = 0; i < m; i++) {
if (flag[i] == 0) {
newData[i * n + idx] = op.apply(data[i * n + idx], 0);
}
}
}
}
return new BlasDoubleMatrix(mat.getMatrixId(), mat.getClock(), m, n, newData);
} else if (!onCol && op.isInplace()) {
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int j = 0; j < n; j++) {
data[idx * n + j] = op.apply(data[idx * n + j], values[j]);
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int j = entry.getIntKey();
flag[j] = 1;
data[idx * n + j] = op.apply(data[idx * n + j], entry.getLongValue());
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int j = idxs[k];
flag[j] = 1;
data[idx * n + j] = op.apply(data[idx * n + j], values[k]);
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
data[idx * n + j] = 0;
}
}
case UNION:
break;
case ALL:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
data[idx * n + j] = op.apply(data[idx * n + j], 0);
}
}
}
}
return mat;
} else {
double[] newData;
if (op.getOpType() == INTERSECTION) {
newData = new double[m * n];
} else {
newData = ArrayCopy.copy(data);
}
if (v.isDense()) {
long[] values = v.getStorage().getValues();
for (int j = 0; j < n; j++) {
newData[idx * n + j] = op.apply(data[idx * n + j], values[j]);
}
} else if (v.isSparse()) {
ObjectIterator<Int2LongMap.Entry> iter = v.getStorage().entryIterator();
while (iter.hasNext()) {
Int2LongMap.Entry entry = iter.next();
int j = entry.getIntKey();
flag[j] = 1;
newData[idx * n + j] = op.apply(data[idx * n + j], entry.getLongValue());
}
} else {
// sorted
int[] idxs = v.getStorage().getIndices();
long[] values = v.getStorage().getValues();
for (int k = 0; k < size; k++) {
int j = idxs[k];
flag[j] = 1;
newData[idx * n + j] = op.apply(data[idx * n + j], values[k]);
}
}
if (!v.isDense()) {
switch(op.getOpType()) {
case INTERSECTION:
break;
case UNION:
break;
case ALL:
for (int j = 0; j < n; j++) {
if (flag[j] == 0) {
newData[idx * n + j] = op.apply(data[idx * n + j], 0);
}
}
}
}
return new BlasDoubleMatrix(mat.getMatrixId(), mat.getClock(), m, n, newData);
}
}
use of com.tencent.angel.ml.math2.vector.IntLongVector in project angel by Tencent.
the class VectorUtils method emptyLike.
private static ComponentVector emptyLike(ComponentVector v) {
ComponentVector result;
if (v instanceof CompIntDoubleVector) {
IntDoubleVector[] parts = new IntDoubleVector[v.getNumPartitions()];
IntDoubleVector[] refParts = ((CompIntDoubleVector) v).getPartitions();
for (int i = 0; i < refParts.length; i++) {
if (null != refParts[i]) {
parts[i] = (IntDoubleVector) emptyLike((SimpleVector) refParts[i]);
}
}
result = new CompIntDoubleVector(((CompIntDoubleVector) v).getMatrixId(), ((CompIntDoubleVector) v).getRowId(), ((CompIntDoubleVector) v).getClock(), ((CompIntDoubleVector) v).getDim(), parts, ((CompIntDoubleVector) v).getSubDim());
} else if (v instanceof CompIntFloatVector) {
IntFloatVector[] parts = new IntFloatVector[v.getNumPartitions()];
IntFloatVector[] refParts = ((CompIntFloatVector) v).getPartitions();
for (int i = 0; i < refParts.length; i++) {
if (null != refParts[i]) {
parts[i] = (IntFloatVector) emptyLike((SimpleVector) refParts[i]);
}
}
result = new CompIntFloatVector(((CompIntFloatVector) v).getMatrixId(), ((CompIntFloatVector) v).getRowId(), ((CompIntFloatVector) v).getClock(), ((CompIntFloatVector) v).getDim(), parts, ((CompIntFloatVector) v).getSubDim());
} else if (v instanceof CompIntLongVector) {
IntLongVector[] parts = new IntLongVector[v.getNumPartitions()];
IntLongVector[] refParts = ((CompIntLongVector) v).getPartitions();
for (int i = 0; i < refParts.length; i++) {
if (null != refParts[i]) {
parts[i] = (IntLongVector) emptyLike((SimpleVector) refParts[i]);
}
}
result = new CompIntLongVector(((CompIntLongVector) v).getMatrixId(), ((CompIntLongVector) v).getRowId(), ((CompIntLongVector) v).getClock(), ((CompIntLongVector) v).getDim(), parts, ((CompIntLongVector) v).getSubDim());
} else if (v instanceof CompIntIntVector) {
IntIntVector[] parts = new IntIntVector[v.getNumPartitions()];
IntIntVector[] refParts = ((CompIntIntVector) v).getPartitions();
for (int i = 0; i < refParts.length; i++) {
if (null != refParts[i]) {
parts[i] = (IntIntVector) emptyLike((SimpleVector) refParts[i]);
}
}
result = new CompIntIntVector(((CompIntIntVector) v).getMatrixId(), ((CompIntIntVector) v).getRowId(), ((CompIntIntVector) v).getClock(), ((CompIntIntVector) v).getDim(), parts, ((CompIntIntVector) v).getSubDim());
} else if (v instanceof CompLongDoubleVector) {
LongDoubleVector[] parts = new LongDoubleVector[v.getNumPartitions()];
LongDoubleVector[] refParts = ((CompLongDoubleVector) v).getPartitions();
for (int i = 0; i < refParts.length; i++) {
if (null != refParts[i]) {
parts[i] = (LongDoubleVector) emptyLike((SimpleVector) refParts[i]);
}
}
result = new CompLongDoubleVector(((CompLongDoubleVector) v).getMatrixId(), ((CompLongDoubleVector) v).getRowId(), ((CompLongDoubleVector) v).getClock(), ((CompLongDoubleVector) v).getDim(), parts, ((CompLongDoubleVector) v).getSubDim());
} else if (v instanceof CompLongFloatVector) {
LongFloatVector[] parts = new LongFloatVector[v.getNumPartitions()];
LongFloatVector[] refParts = ((CompLongFloatVector) v).getPartitions();
for (int i = 0; i < refParts.length; i++) {
if (null != refParts[i]) {
parts[i] = (LongFloatVector) emptyLike((SimpleVector) refParts[i]);
}
}
result = new CompLongFloatVector(((CompLongFloatVector) v).getMatrixId(), ((CompLongFloatVector) v).getRowId(), ((CompLongFloatVector) v).getClock(), ((CompLongFloatVector) v).getDim(), parts, ((CompLongFloatVector) v).getSubDim());
} else if (v instanceof CompLongLongVector) {
LongLongVector[] parts = new LongLongVector[v.getNumPartitions()];
LongLongVector[] refParts = ((CompLongLongVector) v).getPartitions();
for (int i = 0; i < refParts.length; i++) {
if (null != refParts[i]) {
parts[i] = (LongLongVector) emptyLike((SimpleVector) refParts[i]);
}
}
result = new CompLongLongVector(((CompLongLongVector) v).getMatrixId(), ((CompLongLongVector) v).getRowId(), ((CompLongLongVector) v).getClock(), ((CompLongLongVector) v).getDim(), parts, ((CompLongLongVector) v).getSubDim());
} else if (v instanceof CompLongIntVector) {
LongIntVector[] parts = new LongIntVector[v.getNumPartitions()];
LongIntVector[] refParts = ((CompLongIntVector) v).getPartitions();
for (int i = 0; i < refParts.length; i++) {
if (null != refParts[i]) {
parts[i] = (LongIntVector) emptyLike((SimpleVector) refParts[i]);
}
}
result = new CompLongIntVector(((CompLongIntVector) v).getMatrixId(), ((CompLongIntVector) v).getRowId(), ((CompLongIntVector) v).getClock(), ((CompLongIntVector) v).getDim(), parts, ((CompLongIntVector) v).getSubDim());
} else {
throw new AngelException("The operation is not support!");
}
return result;
}
Aggregations