當前位置: 首頁>>代碼示例>>Java>>正文


Java DoubleBuffer.get方法代碼示例

本文整理匯總了Java中java.nio.DoubleBuffer.get方法的典型用法代碼示例。如果您正苦於以下問題:Java DoubleBuffer.get方法的具體用法?Java DoubleBuffer.get怎麽用?Java DoubleBuffer.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.DoubleBuffer的用法示例。


在下文中一共展示了DoubleBuffer.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readPcRasterMapValues

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
public static synchronized void readPcRasterMapValues(Jep jep, String variableName, double[] dest) throws JepException {
    String bufferName = "readPcRasterMapValues" + dest.length;
    Map<Integer, DoubleBuffer> map = readPcRasterMapValuesBuffers.get(jep);
    if (map == null) {
        map = new HashMap<Integer, DoubleBuffer>();
        readPcRasterMapValuesBuffers.put(jep, map);
    }
    DoubleBuffer buffer = map.get(dest.length);
    if (buffer == null) {
        buffer = buffers.get(dest.length);
        if (buffer == null) {
            buffer = createNativeDoubleBuffer(dest.length);
            buffers.put(dest.length, buffer);
        }
        declareDoubleArray(jep, bufferName, buffer);
        map.put(dest.length, buffer);
    }
    jep.eval(bufferName + "[:]=reshape(pcr2numpy(" + variableName + ", 1E31), " + dest.length + ')');
    buffer.rewind();
    buffer.get(dest);
}
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:22,代碼來源:WflowPythonToJavaAdapter.java

示例2: byteArray2DoubleArray

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
@Nullable
private static double[] byteArray2DoubleArray(byte... array) {
    if (array == null) {
        return null;
    }

    final int len = array.length;
    final double[] res = new double[len >> 3];

    try {
        final DoubleBuffer buffer = ByteBuffer.wrap(array).asDoubleBuffer();

        for (int i = 0, iLen = len >> 3; i < iLen; ++i) {
            res[i] = buffer.get();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return res;
}
 
開發者ID:huazhouwang,項目名稱:Synapse,代碼行數:22,代碼來源:DbHelper.java

示例3: testDoubleGet

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
@Test(dataProvider = "doubleViewProvider")
public void testDoubleGet(String desc, IntFunction<ByteBuffer> fbb,
                          Function<ByteBuffer, DoubleBuffer> fbi) {
    ByteBuffer bb = allocate(fbb);
    DoubleBuffer vb = fbi.apply(bb);
    int o = bb.position();

    for (int i = 0; i < vb.limit(); i++) {
        double fromBytes = getDoubleFromBytes(bb, o + i * 8);
        double fromMethodView = bb.getDouble(o + i * 8);
        assertValues(i, fromBytes, fromMethodView, bb);

        double fromBufferView = vb.get(i);
        assertValues(i, fromMethodView, fromBufferView, bb, vb);
    }

    for (int i = 0; i < vb.limit(); i++) {
        double v = getDoubleFromBytes(bb, o + i * 8);
        double a = bb.getDouble();
        assertValues(i, v, a, bb);

        double b = vb.get();
        assertValues(i, a, b, bb, vb);
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:ByteBufferViews.java

示例4: doProcessRow

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
@Override
protected double doProcessRow(ServerDenseDoubleRow row) {
  double sum = 0.0;
  DoubleBuffer data = row.getData();
  int size = row.size();
  for (int i = 0; i < size; i++) {
    sum += data.get(i);
  }
  return sum;
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:11,代碼來源:Sum.java

示例5: doProcessRow

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
@Override
protected double doProcessRow(ServerDenseDoubleRow row1, ServerDenseDoubleRow row2) {
  double sum = 0.0;
  DoubleBuffer data1 = row1.getData();
  DoubleBuffer data2 = row2.getData();
  int size = row1.size();
  for (int i = 0; i < size; i++) {
    sum += data1.get(i) * data2.get(i);
  }
  return sum;
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:12,代碼來源:Dot.java

示例6: doProcessRow

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
@Override
protected double doProcessRow(ServerDenseDoubleRow row) {
  int nnz = 0;
  DoubleBuffer data = row.getData();
  int size = row.size();
  for (int i = 0; i < size; i++) {
    if (data.get(i) != 0) nnz++;
  }
  return nnz;
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:11,代碼來源:Nnz.java

示例7: getVluesofServerDenseDoubleRow

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
/**
 * Get values of specified index in a server row of a server partition.
 * @param row server row of a partition
 * @param index specified index
 * @return values of specified index
 */
private double[] getVluesofServerDenseDoubleRow(ServerRow row, int[] index) {
  int startCol = (int) row.getStartCol();
  DoubleBuffer data = ((ServerDenseDoubleRow) row).getData();
  double[] values = new double[index.length];

  for (int i = 0; i < index.length; i++) {
    values[i] = data.get(index[i] - startCol);
  }

  return values;
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:18,代碼來源:IndexGetFunc.java

示例8: getWorldCoordinates

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
public static Location getWorldCoordinates(GL gl, GLU glu, Location screen, Location store) {
    if (store == null) {
        store = new Location(0,0,0);
    }

    // Modelview matrix
    DoubleBuffer mvBuffer = DoubleBuffer.allocate(16);
    gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, mvBuffer);
    // Projection_matrix
    DoubleBuffer prBuffer = DoubleBuffer.allocate(16);
    gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, prBuffer);
    // Viewport matrix
    IntBuffer vpBuffer = IntBuffer.allocate(16); // 4 is necessary
    gl.glGetIntegerv(GL.GL_VIEWPORT, vpBuffer);

    // 3d coordinates
    DoubleBuffer result = DoubleBuffer.allocate(3);
    glu.gluUnProject(screen.x,
            screen.y,
            screen.z,
            mvBuffer,
            prBuffer,
            vpBuffer,
            result);

    store = new Location(result.get(0), result.get(1), result.get(2));

    return store;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:30,代碼來源:GLTools.java

示例9: getScreenCoordinates

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
public static Location getScreenCoordinates(GL gl, GLU glu, Location worldPosition, Location store) {
    if (store == null) {
        store = new Location(0,0,0);
    }

    // Modelview matrix
    DoubleBuffer mvBuffer = DoubleBuffer.allocate(16);
    gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, mvBuffer);
    // Projection_matrix
    DoubleBuffer prBuffer = DoubleBuffer.allocate(16);
    gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, prBuffer);
    // Viewport matrix
    IntBuffer vpBuffer = IntBuffer.allocate(16);
    gl.glGetIntegerv(GL.GL_VIEWPORT, vpBuffer);

    DoubleBuffer result = DoubleBuffer.allocate(3);

    glu.gluProject(worldPosition.x,
            worldPosition.y,
            worldPosition.z,
            mvBuffer,
            prBuffer,
            vpBuffer,
            result);

    store = new Location(result.get(0), result.get(1), result.get(2));
    
    return store;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:30,代碼來源:GLTools.java

示例10: getDouble

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
public double[] getDouble(Attribute attrib) {
	int pname = getAttrib(attrib);
	DoubleBuffer buf = ByteBuffer.allocateDirect(16).order(ByteOrder.nativeOrder()).asDoubleBuffer();
	gl.glGetDoublev(pname, buf);

	double[] result = new double[buf.capacity()];
	for(int i = 0; i < result.length; i++)
		result[i] = buf.get();

	return result;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:12,代碼來源:JOGLOpenGL.java

示例11: printMatrix

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
private void printMatrix(PrintWriter out, GeometryInfo geometryInfo) {
	ByteBuffer transformation = ByteBuffer.wrap(geometryInfo.getTransformation());
	transformation.order(ByteOrder.LITTLE_ENDIAN);
	DoubleBuffer doubleBuffer = transformation.asDoubleBuffer();
	// Prepare to create the transform matrix.
	double[] matrix = new double[16];
	// Add the first 16 values of the buffer.
	for (int i = 0; i < matrix.length; i++)
		matrix[i] = doubleBuffer.get();
	// Switch from column-major (x.x ... x.y ... x.z ... 0 ...) to row-major orientation (x.x x.y x.z 0 ...)?
	matrix = Matrix.changeOrientation(matrix);
	// List all 16 elements of the matrix as a single space-delimited String object.
	out.println("    <matrix>" + doubleArrayToSpaceDelimitedString(matrix) + "</matrix>");
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:15,代碼來源:ColladaSerializer.java

示例12: bufferToDoubleArray

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
private static double[] bufferToDoubleArray(ByteBuffer buffer) {
	buffer.order(ByteOrder.nativeOrder());
	DoubleBuffer doubles = buffer.asDoubleBuffer();

	if (doubles.hasArray()) {
		return doubles.array();
	} else {
		double[] resultArray = new double[doubles.capacity()];
		doubles.get(resultArray);
		return resultArray;
	}
}
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:13,代碼來源:ThriftBmiBridge.java

示例13: getCursorPos

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
private Vector2f getCursorPos() {
	DoubleBuffer xpos = BufferUtils.createDoubleBuffer(1);
	DoubleBuffer ypos = BufferUtils.createDoubleBuffer(1);
	xpos.rewind();
	xpos.rewind();
	GLFW.glfwGetCursorPos(window.windowID, xpos, ypos);

	double x = xpos.get();
	double y = ypos.get();

	xpos.clear();
	ypos.clear();
	Vector2f result = new Vector2f((float) x, (float) y);
	return result;
}
 
開發者ID:ComunityEngine,項目名稱:CommunityEngine-Java,代碼行數:16,代碼來源:Camera.java

示例14: run

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
/**
 * Called for each document
 * @return cosine similarity of the current document against the input inputVector
 */
@Override
public final Object run() {
    final int size = inputVector.length;

    final byte[] bytes = binaryEmbeddingReader.get(docId).bytes;
    final ByteArrayDataInput input = new ByteArrayDataInput(bytes);
    input.readVInt(); // returns the number of values which should be 1, MUST appear hear since it affect the next calls
    final int len = input.readVInt(); // returns the number of bytes to read
    if(len != size * DOUBLE_SIZE) {
        return 0.0;
    }
    final int position = input.getPosition();
    final DoubleBuffer doubleBuffer = ByteBuffer.wrap(bytes, position, len).asDoubleBuffer();

    final double[] docVector = new double[size];
    doubleBuffer.get(docVector);

    double docVectorNorm = 0.0f;
    double score = 0;
    for (int i = 0; i < size; i++) {
        // doc inputVector norm
        if(cosine) {
            docVectorNorm += docVector[i]*docVector[i];
        }
        // dot product
        score += docVector[i] * inputVector[i];
    }
    if(cosine) {
        // cosine similarity score
        if (docVectorNorm == 0 || magnitude == 0){
            return 0f;
        } else {
            return score / (Math.sqrt(docVectorNorm) * magnitude);
        }
    } else {
        return score;
    }
}
 
開發者ID:lior-k,項目名稱:fast-elasticsearch-vector-scoring,代碼行數:43,代碼來源:VectorScoreScript.java

示例15: getDouble

import java.nio.DoubleBuffer; //導入方法依賴的package包/類
double getDouble(DoubleBuffer vb, int i) { ck(vb.get(i / 8), getDoubleX(i)); return vb.get(i / 8); } 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:2,代碼來源:ByteBufferTest.java


注:本文中的java.nio.DoubleBuffer.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。