Here is an example using std :: tuple along with std :: tie
#include <iostream> #include <armadillo> using namespace arma; std::tuple<mat, mat> phi(int const n, int const q) { ... mat P(n, n); P = ... mat Q, R; qr(Q, R, P); return std::make_tuple(P, Q); } int main() { ... int n, q; std::cout << "Enter the value of parameters n and q respectively:" << std::endl; std::cin >> n >> q; mat P, Q; std::tie(P, Q) = phi(n,q); ... }
With C ++ 17 (and structured binding ) you can do it like this:
#include <iostream> #include <armadillo> using namespace arma; std::tuple<mat, mat> phi(int const n, int const q) { ... mat P(n, n); P = ... mat Q, R; qr(Q, R, P); return {P, Q}; } int main() { ... int n,q; std::cout << "Enter the value of parameters n and q respectively:" << std::endl; std::cin >> n >> q; auto [P, Q] = phi(n,q); ... }
Jonas source share