MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / unflatten_tensor

Method unflatten_tensor

tests/src/IO/WriterTest.h:113–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 }
112
113 MatrixF unflatten_tensor(const VectorF& flattened_tensor) {
114 const size_t size = flattened_tensor.size();
115 const VectorF& A = flattened_tensor;
116 MatrixF tensor(3, 3);
117 if (size == 3) {
118 tensor << A[0], A[2], 0.0,
119 A[2], A[1], 0.0,
120 0.0, 0.0, 0.0;
121 } else if (size == 6) {
122 tensor << A[0], A[5], A[4],
123 A[5], A[1], A[3],
124 A[4], A[3], A[2];
125 } else if (size == 9) {
126 tensor << A[0], A[3], A[6],
127 A[1], A[4], A[7],
128 A[2], A[5], A[8];
129 } else {
130 std::stringstream err_msg;
131 err_msg << "Invalid flattened tensor size: " << size;
132 throw RuntimeError(err_msg.str());
133 }
134 return tensor;
135 }
136
137 MeshPtr write_and_load(const std::string& filename, MeshPtr mesh,
138 bool in_ascii=false) {

Callers

nothing calls this directly

Calls 3

RuntimeErrorClass · 0.85
sizeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected