function hat_A = MultiD_prod(A,f_basis)
[Nx,Nv,n] = size(f_basis);N = Nx*Nv;
[~,~,~,Nz] = size(A);
f_basis_new = zeros(Nx,Nv,n,Nz); 
for i = 1:Nx
    for j = 1:Nz
        f_basis_new(i,:,:,j) = A(:,:,i,j)*reshape(f_basis(i,:,:),Nv,n);
    end
end
f_basis_new = reshape(f_basis_new,N,n,Nz);
f_basis = reshape(f_basis,N,n);
hat_A = zeros(n,n,Nz);
for i = 1:Nz
    hat_A(:,:,i) = f_basis_new(:,:,i)'*f_basis;
end
    