MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / print

Function print

src/api/c/print.cpp:73–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71
72template<typename T>
73static void print(const char *exp, af_array arr, const int precision,
74 std::ostream &os = std::cout, bool transpose = true) {
75 if (exp == NULL) {
76 os << "No Name Array" << std::endl;
77 } else {
78 os << exp << std::endl;
79 }
80
81 const ArrayInfo &info = getInfo(arr);
82
83 std::ios_base::fmtflags backup = os.flags();
84
85 os << "[" << info.dims() << "]\n";
86#ifndef NDEBUG
87 os << " Offset: " << info.getOffset() << std::endl;
88 os << " Strides: [" << info.strides() << "]" << std::endl;
89#endif
90
91 // Handle empty array
92 if (info.elements() == 0) {
93 os << "<empty>" << std::endl;
94 os.flags(backup);
95 return;
96 }
97
98 vector<T> data(info.elements());
99
100 af_array arrT;
101 if (transpose) {
102 AF_CHECK(af_reorder(&arrT, arr, 1, 0, 2, 3));
103 } else {
104 arrT = arr;
105 }
106
107 // FIXME: Use alternative function to avoid copies if possible
108 AF_CHECK(af_get_data_ptr(&data.front(), arrT));
109 const ArrayInfo &infoT = getInfo(arrT);
110
111 printer(os, &data.front(), infoT, infoT.ndims() - 1, precision);
112
113 if (transpose) { AF_CHECK(af_release_array(arrT)); }
114
115 os.flags(backup);
116}
117
118template<typename T>
119static void printSparse(const char *exp, af_array arr, const int precision,

Callers

nothing calls this directly

Calls 9

printerFunction · 0.85
af_reorderFunction · 0.70
af_get_data_ptrFunction · 0.70
af_release_arrayFunction · 0.70
dimsMethod · 0.45
getOffsetMethod · 0.45
stridesMethod · 0.45
elementsMethod · 0.45
ndimsMethod · 0.45

Tested by

no test coverage detected