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

Class Approx1V2

test/approx1.cpp:848–933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

846
847template<typename T>
848class Approx1V2 : public ::testing::Test {
849 protected:
850 typedef typename dtype_traits<T>::base_type BT;
851
852 vector<T> h_gold_cast;
853 vector<T> h_in_cast;
854 vector<BT> h_pos_cast;
855
856 dim4 gold_dims;
857 dim4 in_dims;
858 dim4 pos_dims;
859
860 af_array gold;
861 af_array in;
862 af_array pos;
863
864 Approx1V2() : gold(0), in(0), pos(0) {}
865
866 void SetUp() {}
867
868 void releaseArrays() {
869 if (pos != 0) { ASSERT_SUCCESS(af_release_array(pos)); }
870 if (in != 0) { ASSERT_SUCCESS(af_release_array(in)); }
871 if (gold != 0) { ASSERT_SUCCESS(af_release_array(gold)); }
872 }
873
874 void TearDown() { releaseArrays(); }
875
876 void setTestData(float* h_gold, dim4 gold_dims, float* h_in, dim4 in_dims,
877 float* h_pos, dim4 pos_dims) {
878 releaseArrays();
879
880 gold = 0;
881 in = 0;
882 pos = 0;
883
884 this->gold_dims = gold_dims;
885 this->in_dims = in_dims;
886 this->pos_dims = pos_dims;
887
888 for (int i = 0; i < gold_dims.elements(); ++i) {
889 h_gold_cast.push_back(static_cast<T>(h_gold[i]));
890 }
891 for (int i = 0; i < in_dims.elements(); ++i) {
892 h_in_cast.push_back(static_cast<T>(h_in[i]));
893 }
894 for (int i = 0; i < pos_dims.elements(); ++i) {
895 h_pos_cast.push_back(static_cast<BT>(h_pos[i]));
896 }
897
898 ASSERT_SUCCESS(af_create_array(&gold, &h_gold_cast.front(),
899 gold_dims.ndims(), gold_dims.get(),
900 (af_dtype)dtype_traits<T>::af_type));
901 ASSERT_SUCCESS(af_create_array(&in, &h_in_cast.front(), in_dims.ndims(),
902 in_dims.get(),
903 (af_dtype)dtype_traits<T>::af_type));
904 ASSERT_SUCCESS(af_create_array(&pos, &h_pos_cast.front(),
905 pos_dims.ndims(), pos_dims.get(),

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected