Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <opencv2/opencv.hpp>
- #include <opencv2/cudaarithm.hpp>
- int main()
- {
- try {
- float a_in[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- cv::Mat a(1, 9, CV_32FC1, a_in);
- cv::Mat a_t(a.t());
- float b_in[9] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
- cv::Mat b(9, 1, CV_32FC1, b_in);
- cv::Mat b_t(b.t());
- cv::Mat result, result_t;
- // Regular gemm
- cv::gemm(a, b, 1.0, cv::Mat(), 0.0, result);
- cv::gemm(a_t, b_t, 1.0, cv::Mat(), 0.0, result_t);
- std::cout << "result = " << result << std::endl;
- std::cout << "result_t = " << result_t << std::endl;
- } catch (cv::Exception& e) {
- std::cerr << e.what();
- return -1;
- }
- }
- /* Prints out:
- result = [45]
- result_t = [1, 1, 1, 1, 1, 1, 1, 1, 1;
- 2, 2, 2, 2, 2, 2, 2, 2, 2;
- 3, 3, 3, 3, 3, 3, 3, 3, 3;
- 4, 4, 4, 4, 4, 4, 4, 4, 4;
- 5, 5, 5, 5, 5, 5, 5, 5, 5;
- 6, 6, 6, 6, 6, 6, 6, 6, 6;
- 7, 7, 7, 7, 7, 7, 7, 7, 7;
- 8, 8, 8, 8, 8, 8, 8, 8, 8;
- 9, 9, 9, 9, 9, 9, 9, 9, 9]
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement