Умножение матриц, помогите найти ошибку
Дана матрица, которую нужно транспонировать, а затем умножить на получившуюся матрицу. Помогите найти ошибку, выводит совершенно не те числа, хотя транспонирует правильно. (ввод матрицы из файла).
входные данные:
3 3
1 2 3
4 5 6
7 8 9
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
fstream f;
int inpArr (int *n, int *m, float**a, float**w, float **c) {
if(f.eof()) {
*a = new float [(*n)*(*m)];
return 1;
}
f >> *n;
f >> *m;
*a = new float [(*n)*(*m)];
char b;
for (int i = 0; i < *n; i++) {
if(f.eof()) break;
for (int j = 0; j < *m; j++)
{
if(f.eof()) break;
f >> *(*a+(*m)*i+j);
}
b = 0;
while (b != '\n' && !f.eof())
{
b = f.get();
}
}
*w = new float [(*n)*(*m)];
for (int i = 0; i < *n; i++) {
for (int j = 0; j < *m; j++)
*(*w+(*m)*j+i) = *(*a+(*m)*i+j); }
*c = new float [(*n)*(*m)];
}
void realOutArr(int n, int m, const float *a, const float *w, const float *c) {
for (int i=0; i < n; i++) {
f << " " << i << "-string: ";
for (int j = 0; j < m; j++)
{f << " " << *(a+m*i+j);
f << "\n";}}
for (int i=0; i < n; i++) {
cout << " " << i << "-string: ";
for (int j = 0; j < m; j++)
{cout << " " << *(a+m*i+j);}
cout << "\n";}
cout << endl << "Транспонированная матрица" << endl << endl;
for (int i=0; i < n; i++) {
cout << " " << i << "-string: ";
for (int j = 0; j < m; j++)
{cout << " " << *(w+m*i+j);}
cout << "\n";}
}
void Ortonorm(int n, int m, float *a, float *w, float *c) {
cout << endl << "Заданная матрица, умноженная на транспонированную" << endl << endl;
for(int i=0; i < n; i++)
{
for(int j=0; j < m; j++){
*(c+m*i+j)=0;
for(int k=0; k < m; k++)
*(c+m*i+j)+= ((*a)+m*i+k) * ((*w)+m*k+j);
}
}
for (int i=0; i < n; i++) {
cout << " " << i << "-string: ";
for (int j = 0; j < m; j++)
{cout << " " << *(c+m*i+j);}
cout << "\n";}
//Вывод
}
int main() {
setlocale(LC_ALL, "Russian");
int n, m;
float sum, square;
float* arrA;
float* arrW;
float* arrC;
f.open("in.txt", ios::in);
n=1; m=1;
inpArr(&n, &m, &arrA, &arrW, &arrC);
f.close();
f.open ("out.txt", ios::out);
realOutArr(n, m, arrA, arrW, arrC);
Ortonorm(n, m, arrA, arrW, arrC);
f.close();
return 0;
}

