MCPcopy Create free account
hub / github.com/Kitware/VTK / ArrayTransposeMatrix

Function ArrayTransposeMatrix

Infovis/Core/Testing/Cxx/ArrayTransposeMatrix.cxx:21–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19 } while (false)
20
21int ArrayTransposeMatrix(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
22{
23 std::cout << setprecision(17);
24
25 try
26 {
27 vtkSmartPointer<vtkSparseArray<double>> source = vtkSmartPointer<vtkSparseArray<double>>::New();
28 source->Resize(vtkArrayExtents(3, 2));
29 source->AddValue(vtkArrayCoordinates(0, 1), 1);
30 source->AddValue(vtkArrayCoordinates(1, 0), 2);
31 source->AddValue(vtkArrayCoordinates(2, 0), 3);
32
33 std::cout << "source matrix:\n";
34 vtkPrintMatrixFormat(std::cout, source.GetPointer());
35
36 vtkSmartPointer<vtkArrayData> source_data = vtkSmartPointer<vtkArrayData>::New();
37 source_data->AddArray(source);
38
39 vtkSmartPointer<vtkTransposeMatrix> transpose = vtkSmartPointer<vtkTransposeMatrix>::New();
40 transpose->SetInputData(source_data);
41 transpose->Update();
42
43 vtkSparseArray<double>* const output = vtkSparseArray<double>::SafeDownCast(
44 transpose->GetOutput()->GetArray(static_cast<vtkIdType>(0)));
45 std::cout << "output matrix:\n";
46 vtkPrintMatrixFormat(std::cout, output);
47
48 test_expression(output);
49 test_expression(output->GetExtent(0).GetSize() == 2);
50 test_expression(output->GetExtent(1).GetSize() == 3);
51
52 test_expression(output->GetValue(vtkArrayCoordinates(0, 0)) == 0);
53 test_expression(output->GetValue(vtkArrayCoordinates(0, 1)) == 2);
54 test_expression(output->GetValue(vtkArrayCoordinates(0, 2)) == 3);
55 test_expression(output->GetValue(vtkArrayCoordinates(1, 0)) == 1);
56 test_expression(output->GetValue(vtkArrayCoordinates(1, 1)) == 0);
57 test_expression(output->GetValue(vtkArrayCoordinates(1, 2)) == 0);
58
59 return 0;
60 }
61 catch (std::exception& e)
62 {
63 std::cerr << e.what() << std::endl;
64 return 1;
65 }
66}

Callers

nothing calls this directly

Calls 14

test_expressionFunction · 0.85
AddValueMethod · 0.80
NewFunction · 0.50
ResizeMethod · 0.45
GetPointerMethod · 0.45
AddArrayMethod · 0.45
SetInputDataMethod · 0.45
UpdateMethod · 0.45
GetArrayMethod · 0.45
GetOutputMethod · 0.45
GetSizeMethod · 0.45
GetExtentMethod · 0.45

Tested by

no test coverage detected