I have the following code, where the kronecker product of 2 arrays is computed. In this code I want to return the array C which is the kronecker product of the two arrays back to the main function. I have tried pointers instead of void but I am not able to do it. Also I want tje function to compute the kroecker product of the arrays of any sizes so I have used templates here. How can I return the array C (Kronecker product) back to the main.
#include <iostream>
using namespace std;
#include <any>
#include <vector>
template <size_t size_x1, size_t size_y1, size_t size_x2, size_t size_y2>
void Kroneckerproduct(int (&A)[size_x1][size_y1],int (&B)[size_x2][size_y2])
{
int rowa=size_x1;
int cola=size_y1;
int rowb=size_x2;
int colb=size_y2;
int C[rowa * rowb][cola * colb];
// i loops till rowa
for (int i = 0; i < rowa; i++) {
//for (int i = 0; i < size_x1; i++) {
// k loops till rowb
for (int k = 0; k < rowb; k++) {
// for (int k = 0; k < size_x2; k++) {
// j loops till cola
for (int j = 0; j < cola; j++) {
//for (int j = 0; j < size_y1; j++) {
// l loops till colb
for (int l = 0; l < colb; l++) {
// for (int l = 0; l < size_y2; l++) {
// Each element of matrix A is
// multiplied by whole Matrix B
// resp and stored as Matrix C
C[i + l + 1][j + k + 1] = A[i][j] * B[k][l];
cout << C[i + l + 1][j + k + 1] << " ";
}
}
cout << endl;
}
}
}
int main()
{
int A[3][2] = { { 1, 2 }, { 3, 4 }, { 1, 0 } },
B[2][3] = { { 0, 5, 2 }, { 6, 7, 3 } };
Kroneckerproduct(A, B);
return 0;
}