Search in sources :

Example 31 with DoubleBuffer

use of java.nio.DoubleBuffer in project angel by Tencent.

the class Axpy method doUpdate.

@Override
protected void doUpdate(ServerDenseDoubleRow[] rows, double[] scalars) {
    try {
        rows[1].getLock().writeLock().lock();
        DoubleBuffer xData = rows[0].getData();
        DoubleBuffer yData = rows[1].getData();
        double a = scalars[0];
        int size = rows[0].size();
        for (int i = 0; i < size; i++) {
            yData.put(i, a * xData.get(i) + yData.get(i));
        }
    } finally {
        rows[1].getLock().writeLock().unlock();
    }
}
Also used : DoubleBuffer(java.nio.DoubleBuffer)

Example 32 with DoubleBuffer

use of java.nio.DoubleBuffer in project angel by Tencent.

the class Ceil method doUpdate.

@Override
protected void doUpdate(ServerDenseDoubleRow[] rows) {
    try {
        rows[1].getLock().writeLock().lock();
        DoubleBuffer from = rows[0].getData();
        DoubleBuffer to = rows[1].getData();
        int size = rows[0].size();
        for (int i = 0; i < size; i++) {
            to.put(i, Math.ceil(from.get(i)));
        }
    } finally {
        rows[1].getLock().writeLock().unlock();
    }
}
Also used : DoubleBuffer(java.nio.DoubleBuffer)

Example 33 with DoubleBuffer

use of java.nio.DoubleBuffer in project angel by Tencent.

the class Copy method doUpdate.

@Override
protected void doUpdate(ServerDenseDoubleRow[] rows) {
    try {
        rows[1].getLock().writeLock().lock();
        DoubleBuffer source = rows[0].getData();
        DoubleBuffer target = rows[1].getData();
        int size = rows[0].size();
        for (int i = 0; i < size; i++) {
            target.put(i, source.get(i));
        }
    } finally {
        rows[1].getLock().writeLock().unlock();
    }
}
Also used : DoubleBuffer(java.nio.DoubleBuffer)

Example 34 with DoubleBuffer

use of java.nio.DoubleBuffer in project angel by Tencent.

the class Div method doUpdate.

@Override
protected void doUpdate(ServerDenseDoubleRow[] rows) {
    try {
        rows[2].getLock().writeLock().lock();
        DoubleBuffer from1 = rows[0].getData();
        DoubleBuffer from2 = rows[1].getData();
        DoubleBuffer to = rows[2].getData();
        int size = rows[0].size();
        for (int i = 0; i < size; i++) {
            to.put(i, from1.get(i) / from2.get(i));
        }
    } finally {
        rows[2].getLock().writeLock().unlock();
    }
}
Also used : DoubleBuffer(java.nio.DoubleBuffer)

Example 35 with DoubleBuffer

use of java.nio.DoubleBuffer in project angel by Tencent.

the class DivS method doUpdate.

@Override
protected void doUpdate(ServerDenseDoubleRow[] rows, double[] scalars) {
    try {
        rows[1].getLock().writeLock().lock();
        DoubleBuffer from = rows[0].getData();
        DoubleBuffer to = rows[1].getData();
        double value = scalars[0];
        int size = rows[0].size();
        for (int i = 0; i < size; i++) {
            to.put(i, from.get(i) / value);
        }
    } finally {
        rows[1].getLock().writeLock().unlock();
    }
}
Also used : DoubleBuffer(java.nio.DoubleBuffer)

Aggregations

DoubleBuffer (java.nio.DoubleBuffer)162 ByteBuffer (java.nio.ByteBuffer)39 FloatBuffer (java.nio.FloatBuffer)26 IntBuffer (java.nio.IntBuffer)25 ShortBuffer (java.nio.ShortBuffer)22 LongBuffer (java.nio.LongBuffer)14 CharBuffer (java.nio.CharBuffer)11 BufferOverflowException (java.nio.BufferOverflowException)8 IOException (java.io.IOException)5 BufferUnderflowException (java.nio.BufferUnderflowException)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 ServerDenseDoubleRow (com.tencent.angel.ps.impl.matrix.ServerDenseDoubleRow)4 Test (org.junit.Test)4 InvalidMarkException (java.nio.InvalidMarkException)3 Random (java.util.Random)3 BytePointer (org.bytedeco.javacpp.BytePointer)3 DoublePointer (org.bytedeco.javacpp.DoublePointer)3 FloatPointer (org.bytedeco.javacpp.FloatPointer)3 IntPointer (org.bytedeco.javacpp.IntPointer)3