本文整理汇总了Java中org.ujmp.core.Matrix.setAsObject方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.setAsObject方法的具体用法?Java Matrix.setAsObject怎么用?Java Matrix.setAsObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ujmp.core.Matrix
的用法示例。
在下文中一共展示了Matrix.setAsObject方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calc
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
public final void calc(final Matrix source, final Matrix target) {
if (source == target) {
throw new RuntimeException("cannot transpose into original matrix");
}
if (source.isSparse() && source instanceof SparseMatrix && target.isSparse()
&& target instanceof SparseMatrix) {
Transpose.SPARSEMATRIX.calc((SparseMatrix) source, (SparseMatrix) target);
} else if (source instanceof DenseDoubleMatrix2D && target instanceof DenseDoubleMatrix2D) {
Transpose.DENSEDOUBLEMATRIX2D.calc((DenseDoubleMatrix2D) source,
(DenseDoubleMatrix2D) target);
} else if (source instanceof DenseMatrix2D && target instanceof DenseMatrix2D) {
Transpose.DENSEMATRIX2D.calc((DenseMatrix2D) source, (DenseMatrix2D) target);
} else if (source instanceof DenseMatrix && target instanceof DenseMatrix) {
Transpose.DENSEMATRIX.calc((DenseMatrix) source, (DenseMatrix) target);
} else {
VerifyUtil.verify2D(source);
VerifyUtil.verify2D(target);
VerifyUtil.verifyEquals(source.getRowCount(), target.getColumnCount(),
"matrices have wrong size");
VerifyUtil.verifyEquals(source.getColumnCount(), target.getRowCount(),
"matrices have wrong size");
for (long[] c : source.allCoordinates()) {
Object o = source.getAsObject(c);
target.setAsObject(o, Coordinates.transpose(c));
}
}
}
示例2: calcNew
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
public final Matrix calcNew() {
// Matrix result = MatrixFactory.zeros(getSource().getValueType(),
// getSize());
Matrix result = Matrix.Factory.zeros(getValueType(), getSize());
for (long[] c : result.allCoordinates()) {
result.setAsObject(getObject(c), c);
}
if (getMetaData() != null) {
result.setMetaData(getMetaData().clone());
}
return result;
}
示例3: calcNew
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
public static Matrix calcNew(ValueType valueType, Matrix source) {
Matrix ret = Matrix.Factory.zeros(valueType, source.getSize());
for (long[] c : source.availableCoordinates()) {
ret.setAsObject(source.getAsObject(c), c);
}
MapMatrix<String, Object> a = source.getMetaData();
if (a != null) {
ret.setMetaData(a.clone());
}
return ret;
}
示例4: setObject
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
public void setObject(Object o, long row, long column) {
Matrix m = columns.get(column);
if (m == null) {
m = new DefaultSparseObjectMatrix(getRowCount(), 1);
columns.put(column, m);
}
m.setAsObject(o, row, 0);
}
示例5: setObject
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
public void setObject(Object o, long row, long column) {
Matrix m = rows.get(row);
if (m == null) {
// TODO: there should be a faster implementation than this:
m = new DefaultSparseObjectMatrix((long) 1, getColumnCount());
rows.put(row, m);
}
m.setAsObject(o, 0, column);
}
示例6: testSelectedCoordinatesString
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public final void testSelectedCoordinatesString() throws Exception {
Matrix m = getTestMatrix();
Matrix mTest = createMatrixWithAnnotation(2, 3);
mTest.setAsObject(mTest.getAsObject(0, 0), 0, 0);
mTest.setAsObject(mTest.getAsObject(0, 1), 0, 1);
mTest.setAsObject(mTest.getAsObject(0, 2), 0, 2);
mTest.setAsObject(mTest.getAsObject(1, 0), 1, 0);
mTest.setAsObject(mTest.getAsObject(1, 1), 1, 1);
mTest.setAsObject(mTest.getAsObject(1, 2), 1, 2);
List<Coordinates> clist = new ArrayList<Coordinates>();
for (long[] c : m.selectedCoordinates("1:3;:")) {
clist.add(Coordinates.wrap(c).clone());
}
assertEquals(getLabel(), 6, clist.size());
assertTrue(getLabel(), clist.contains(Coordinates.wrap(0, 0)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(0, 1)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(0, 2)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(1, 0)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(1, 1)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(1, 2)));
if (m instanceof Erasable) {
((Erasable) m).erase();
}
}
示例7: testSelectedCoordinates
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public final void testSelectedCoordinates() throws Exception {
Matrix m = getTestMatrix();
Matrix mTest = createMatrixWithAnnotation(2, 3);
mTest.setAsObject(mTest.getAsObject(0, 0), 0, 0);
mTest.setAsObject(mTest.getAsObject(0, 1), 0, 1);
mTest.setAsObject(mTest.getAsObject(0, 2), 0, 2);
mTest.setAsObject(mTest.getAsObject(1, 0), 1, 0);
mTest.setAsObject(mTest.getAsObject(1, 1), 1, 1);
mTest.setAsObject(mTest.getAsObject(1, 2), 1, 2);
Iterator<long[]> ci = m.selectedCoordinates(new long[] { 0, 1 }, new long[] { 0, 1, 2 })
.iterator();
long[] c = ci.next();
assertTrue(getLabel(), Coordinates.equals(c, new long[] { 0, 0 }));
c = ci.next();
assertTrue(getLabel(), Coordinates.equals(c, new long[] { 0, 1 }));
c = ci.next();
assertTrue(getLabel(), Coordinates.equals(c, new long[] { 0, 2 }));
c = ci.next();
assertTrue(getLabel(), Coordinates.equals(c, new long[] { 1, 0 }));
c = ci.next();
assertTrue(getLabel(), Coordinates.equals(c, new long[] { 1, 1 }));
c = ci.next();
assertTrue(getLabel(), Coordinates.equals(c, new long[] { 1, 2 }));
assertFalse(getLabel(), ci.hasNext());
if (m instanceof Erasable) {
((Erasable) m).erase();
}
}
示例8: getMatrix
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
private Matrix getMatrix(PRow row) throws Exception {
ARow aRow = (ARow) row;
int columns = aRow.getAdditionalValues().size() + 1;
Matrix m = DenseObjectMatrix2D.Factory.zeros(1, columns);
m.setAsObject(getSingleValue(aRow.getExpression()), 0, 0);
int i = 1;
for (PCommaValue commaValue : aRow.getAdditionalValues()) {
PExpression expr = ((ACommaValue) commaValue).getExpression();
m.setAsObject(getSingleValue(expr), 0, i++);
}
return m;
}
示例9: setObject
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
public void setObject(Object value, long row, long column) {
long rows = 0;
for (Matrix m : variable) {
rows += m.getRowCount();
if (rows > row) {
long r = row - rows + m.getRowCount();
if (column < m.getColumnCount()) {
m.setAsObject(value, r, column);
return;
} else {
return;
}
}
}
}
示例10: saveJunctionAttributeValues
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
/**
* Analysis Information in a Node
*
* @param matrix
* Information will be stored in the Matrix
* @param nodeToAnalysis
* Node To Analysis
* @param nodeList
* Node List
* @param matchAttributeList
*/
@SuppressWarnings("unchecked")
public void saveJunctionAttributeValues(Matrix matrix,
final String nodeToAnalysis,
final List<Element> nodeList,
final List<String> matchAttributeList)
{
final int nodeListSize = nodeList.size();
System.out.println(nodeToAnalysis +" \'s count: " + nodeListSize);
for(int i = 0; i<nodeListSize; i++)
{
//Get a node from the node list
final Element element = nodeList.get(i);
//match attribute information
//System.out.println("! ----------------------------------------------- !");
//System.out.println("! Start Node -- " + element.getName() + " -- Start Node !");
final List<Attribute> listAttribute = element.attributes();
Map<String, String> mapCurrently = new HashMap<String, String>();
for (final Attribute attr : listAttribute)
{
//Save all Attribute and it's Value in a Key-Value Map
mapCurrently.put(attr.getName(),attr.getValue());
}
if(nodeToAnalysis.equals(SumoXmlAttributeMatch.JUNCTION))
{
String matchAttribute = "";
//Match all demanded Attributes
for(int j = 0; j<matchAttributeList.size(); j++)
{
matchAttribute = matchAttributeList.get(j);
if(mapCurrently.containsKey(matchAttribute))
{
final String attributeValue = mapCurrently.get(matchAttribute);
//System.out.println(" = > " + matchAttribute + " = " + attributeValue + ";" );
matrix.setAsObject(attributeValue, i,j);
}
}
}
//System.out.println("! End Node -- " + element.getName() + " -- End Node !");
//System.out.println("! ----------------------------------------------- !\n");
}
}
示例11: saveEdgeAttributeValues
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
/**
* Analysis Information in a Node
*
* @param matrix
* Information will be stored in the Matrix
* @param nodeToAnalysis
* Node To Analysis
* @param nodeList
* Node List
* @param matchAttributeList
*/
@SuppressWarnings("unchecked")
public void saveEdgeAttributeValues(Matrix matrix,
final String nodeToAnalysis,
final List<Element> nodeList,
final List<String> matchAttributeList)
{
final int nodeListSize = nodeList.size();
System.out.println(nodeToAnalysis +" \'s count: " + nodeListSize);
for(int i = 0; i<nodeListSize; i++)
{
//Get a node from the node list
final Element element = nodeList.get(i);
//match attribute information
//System.out.println("! ----------------------------------------------- !");
//System.out.println("! Start Node -- " + element.getName() + " -- Start Node !");
final List<Attribute> listAttribute = element.attributes();
Map<String, String> mapCurrently = new HashMap<String, String>();
for (final Attribute attr : listAttribute)
{
//Save all Attribute and it's Value in a Key-Value Map
mapCurrently.put(attr.getName(),attr.getValue());
}
if(nodeToAnalysis.equals(SumoXmlAttributeMatch.EDGE))
{
//Sub Node
String start_node = mapCurrently.get("from") + "@" + mapCurrently.get("id");
String end_node = mapCurrently.get("to") + "@" + mapCurrently.get("id");
double speed = 0, length = 0, start_x = 0, start_y = 0, end_x = 0, end_y = 0;
final List<Element> subNodeList = element.selectNodes("lane");
int numLanes = subNodeList.size();
for(int p = 0; p<numLanes; p++)
{
speed += Double.parseDouble(subNodeList.get(p).attribute("speed").getValue());
length += Double.parseDouble(subNodeList.get(p).attribute("length").getValue());
final String[] shape = subNodeList.get(p).attribute("shape").getValue().split(",| ");
start_x += Double.parseDouble(shape[0]);
start_y += Double.parseDouble(shape[1]);
end_x += Double.parseDouble(shape[shape.length-2]);
end_y += Double.parseDouble(shape[shape.length-1]);
}
speed /= numLanes;
length /= numLanes;
start_x /= numLanes;
start_y /= numLanes;
end_x /= numLanes;
end_y /= numLanes;
matrix.setAsObject(mapCurrently.get("id"), i,0);
matrix.setAsObject(mapCurrently.get("from"), i,1);
matrix.setAsObject(mapCurrently.get("to"), i,2);
matrix.setAsObject(Integer.toString(numLanes), i,3);
matrix.setAsObject(Double.toString(speed), i,4);
matrix.setAsObject(Double.toString(length), i,5);
matrix.setAsObject(start_node, i,6);
matrix.setAsObject(Double.toString(start_x), i,7);
matrix.setAsObject(Double.toString(start_y), i,8);
matrix.setAsObject(end_node, i,9);
matrix.setAsObject(Double.toString(end_x), i,10);
matrix.setAsObject(Double.toString(end_y), i,11);
}
//System.out.println("! End Node -- " + element.getName() + " -- End Node !");
//System.out.println("! ----------------------------------------------- !\n");
}
}
示例12: saveConnectionAttributeValues
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
/**
* Analysis Information in a Node
*
* @param matrix
* Information will be stored in the Matrix
* @param nodeToAnalysis
* Node To Analysis
* @param nodeList
* Node List
* @param matchAttributeList
*/
@SuppressWarnings("unchecked")
public void saveConnectionAttributeValues(Matrix matrix,
final String nodeToAnalysis,
final List<Element> nodeList,
final List<String> matchAttributeList)
{
final int nodeListSize = nodeList.size();
System.out.println(nodeToAnalysis +" \'s count: " + nodeListSize);
for(int i = 0; i<nodeListSize; i++)
{
//Get a node from the node list
final Element element = nodeList.get(i);
//match attribute information
//System.out.println("! ----------------------------------------------- !");
//System.out.println("! Start Node -- " + element.getName() + " -- Start Node !");
final List<Attribute> listAttribute = element.attributes();
Map<String, String> mapCurrently = new HashMap<String, String>();
for (final Attribute attr : listAttribute)
{
//Save all Attribute and it's Value in a Key-Value Map
mapCurrently.put(attr.getName(),attr.getValue());
}
if(nodeToAnalysis.equals(SumoXmlAttributeMatch.CONNECTION))
{
String matchAttribute = "";
//Match all demanded Attributes
for(int j = 0; j<matchAttributeList.size(); j++)
{
matchAttribute = matchAttributeList.get(j);
if(mapCurrently.containsKey(matchAttribute))
{
final String attributeValue = mapCurrently.get(matchAttribute);
//System.out.println(" = > " + matchAttribute + " = " + attributeValue + ";" );
matrix.setAsObject(attributeValue, i,j);
}
}
}
//System.out.println("! End Node -- " + element.getName() + " -- End Node !");
//System.out.println("! ----------------------------------------------- !\n");
}
}
示例13: connectionMatrixManage
import org.ujmp.core.Matrix; //导入方法依赖的package包/类
/**
* Connection Matrix Management
* @param null
*/
private void connectionMatrixManage(final Matrix matrixEdge, final Matrix matrixConnection)
{
final long edgeMatrixRowCount = matrixEdge.getRowCount();
final long connectionMatrixRowCount = matrixConnection.getRowCount();
int countorg = 1;
int countdes = 1;
//将连接矩阵中边到边的信息改为点到点的信息
for(int i=0; i<edgeMatrixRowCount; i++)
{
String edgeID = matrixEdge.getAsString(i,0); //边名
String fromoNodeID = matrixEdge.getAsString(i,1); //边的起点
String internalFromNode = matrixEdge.getAsString(i,6); //边的内部起点
String internalFromNode_x = matrixEdge.getAsString(i,7);//边的内部起点X坐标
String internalFromNode_y = matrixEdge.getAsString(i,8);//边的内部起点Y坐标
String toNodeID = matrixEdge.getAsString(i,2); //边的终点
String internalToNode = matrixEdge.getAsString(i,9); //边的内部终点
String internalToNode_x = matrixEdge.getAsString(i,10); //边的内部终点X坐标
String internalToNode_y = matrixEdge.getAsString(i,11); //边的内部终点Y坐标
//处理ODList内容为内部点
int orgindex = originList.indexOf(edgeID);
if(orgindex != -1)
{
String org = internalFromNode+" "+internalFromNode_x+" "+internalFromNode_y;
originList.set(orgindex, org);
System.out.println("originList"+countorg +": "+internalFromNode);
countorg++;
}
int desindex = destinationList.indexOf(edgeID);
if(desindex != -1)
{
String des = internalToNode+" "+internalToNode_x+" "+internalToNode_y;
destinationList.set(desindex, des);
System.out.println("destinationList"+countdes+": "+internalToNode);
countdes++;
}
for(int j=0; j<connectionMatrixRowCount; j++)
{
String connFrom = matrixConnection.getAsString(j,0);
String connTo = matrixConnection.getAsString(j,3);
if(connFrom.equals(matrixEdge.getAsString(i,0)))
{//替换起始边为起始点
matrixConnection.setAsObject(internalToNode, j,0);
matrixConnection.setAsObject(internalToNode_x, j,1);
matrixConnection.setAsObject(internalToNode_y, j,2);
matrixConnection.setAsObject(toNodeID, j,7);
}
if(connTo.equals(matrixEdge.getAsString(i,0)))
{//替换终止边为终止点
matrixConnection.setAsObject(internalFromNode, j,3);
matrixConnection.setAsObject(internalFromNode_x, j,4);
matrixConnection.setAsObject(internalFromNode_y, j,5);
matrixConnection.setAsObject(fromoNodeID, j,6);
}
}
}
}