当前位置: 首页>>代码示例>>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;未经允许,请勿转载。