Package java.nio

Examples of java.nio.DoubleBuffer


        int rowStartRegion = getMatrixRegion(row, 0);
        int rowEndRegion = getMatrixRegion(row + 1, 0);
        double[] rowVal = new double[cols];
        if (rowStartRegion == rowEndRegion) {
            int rowStartIndex = getRegionOffset(row, 0);
            DoubleBuffer region = matrixRegions[rowStartRegion];
            for (int col = 0; col < cols; ++col)
                rowVal[col] = region.get(col + rowStartIndex);
        }
        else {
            DoubleBuffer firstRegion = matrixRegions[rowStartRegion];
            DoubleBuffer secondRegion = matrixRegions[rowEndRegion];
            int rowStartIndex = getRegionOffset(row, 0);
            int rowOffset = 0;
            for (; rowStartIndex + rowOffset < MAX_ELEMENTS_PER_REGION;
                     ++rowOffset) {
                rowVal[rowOffset] = firstRegion.get(rowOffset + rowStartIndex);
            }
            // Fill from the second region
            for (int i = 0; rowOffset < rowVal.length; ++i, ++rowOffset)
                rowVal[rowOffset] = secondRegion.get(i);
        }
        return rowVal;
    }
View Full Code Here


    public double[][] toDenseArray() {
        if (matrixRegions.length > 1)
            throw new UnsupportedOperationException(
                "matrix is too large to fit into memory");
        double[][] m = new double[rows][cols];
        DoubleBuffer b = matrixRegions[0];
        b.rewind();
        for (int row = 0; row < rows; ++row)
            b.get(m[row]);
        return m;
    }
View Full Code Here

            cellGroup = new CellGroup<SecurityDoubleValueCell>(activeRowId);
        }
        String label = dbItem.getKey().getColumnQualifier().toString();
        byte [] valueBytes = dbItem.getValue().get();
        ByteBuffer buffer = ByteBuffer.wrap(valueBytes);
        DoubleBuffer dbBuffer = buffer.asDoubleBuffer();
        double value = valueBytes.length > 0 ? dbBuffer.get() : Defaults.defaultValue(double.class);
        String colVis = dbItem.getKey().getColumnVisibility().toString();
        String colFam = dbItem.getKey().getColumnFamily().toString();
        long timestamp = dbItem.getKey().getTimestamp();
        SecurityDoubleValueCell cell;
        if(recordCF & recordTsAndColVis) {
View Full Code Here

  /** Bulk input of a double array. */
  public double[] readDoubles (int length) throws KryoException {
    if (capacity - position >= length * 8 && isNativeOrder()) {
      double[] array = new double[length];
      DoubleBuffer buf = niobuffer.asDoubleBuffer();
      buf.get(array);
      position += length * 8;
      niobuffer.position(position);
      return array;
    } else
      return super.readDoubles(length);
View Full Code Here

  }

  /** Bulk output of a double array. */
  public void writeDoubles (double[] object) throws KryoException {
    if (capacity - position >= object.length * 8 && isNativeOrder()) {
      DoubleBuffer buf = niobuffer.asDoubleBuffer();
      buf.put(object);
      position += object.length * 8;
    } else
      super.writeDoubles(object);
  }
View Full Code Here

                         i < 512 ? 0 : MAGIC, array[i]);
        }
    }
    public void testWrappedDoubleArrayArguent() {
        double[] array = new double[1024];
        DoubleBuffer buf  = DoubleBuffer.wrap(array, 512, 512);
        final double MAGIC = -118.625;
        lib.fillDoubleBuffer(buf, 512, MAGIC);
        for (int i=0;i < array.length;i++) {
            assertEquals("Bad value at index " + i,
                         i < 512 ? 0 : MAGIC, array[i]);
View Full Code Here

    }
    public void testDoubleBufferPut() {
        final double MAGIC = 1234.5678;
        Memory m = new Memory(8);
        ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder());
        DoubleBuffer db = buf.asDoubleBuffer();
        db.put(MAGIC).flip();
        assertEquals("Int not written to memory", MAGIC, m.getDouble(0), 0d);
    }
View Full Code Here

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_DOUBLE_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 8);
          DoubleBuffer doublebuf = buf.asDoubleBuffer();
          double[] doubleArray = new double[arraySize];
          for (int i = arrayStart; i < arrayStart + arraySize; i++) {
            doubleArray[i - arrayStart] = Double.longBitsToDouble(this.getLongHeap().heap[i]);
          }
          doublebuf.put(doubleArray);
          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        }

      } else if (null != aSofa.getSofaURI()) {
View Full Code Here

        for(int row=0; row<hcore.vertexcount/hcore.stripsize; row++) {
          gl.glActiveTexture(GL.GL_TEXTURE0);
          gl.glClientActiveTexture(GL.GL_TEXTURE0);
         
          DoubleBuffer db = hcore.getVertexDb();
          db.position(vertex_i*3);
          gl.glVertexPointer(3, GL.GL_DOUBLE, 0, db);
          gl.glNormalPointer(GL.GL_DOUBLE, 0, db);
         
          DoubleBuffer texDb = hcore.getTexDb();
          texDb.position(texcoord_i*2);
          gl.glTexCoordPointer(2, GL.GL_DOUBLE, 0, texDb);

          // TODO can be removed when texture blending is not used
          gl.glActiveTexture(GL.GL_TEXTURE1);
          gl.glClientActiveTexture(GL.GL_TEXTURE1);
View Full Code Here

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_DOUBLE_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 8);
          DoubleBuffer doublebuf = buf.asDoubleBuffer();
          double[] doubleArray = new double[arraySize];
          for (int i = arrayStart; i < arrayStart + arraySize; i++) {
            doubleArray[i - arrayStart] = Double.longBitsToDouble(this.getLongHeap().heap[i]);
          }
          doublebuf.put(doubleArray);
          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        }

      } else if (null != aSofa.getSofaURI()) {
View Full Code Here

TOP

Related Classes of java.nio.DoubleBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.