/*
- * Copyright (C) 2014 Intel Corporation.
- */
+// Copyright (c) 2015 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
#include "matrix-ops.h"
#include <math.h>
-#include <stdio.h>
+
void transpose (int rows, int cols, double m[rows][cols], double m_trans[cols][rows])
{
result [i][k] += m1[i][j] * m2 [j][k];
}
}
+
+
void invert (int s, double m[s][s], double m_inv[s][s])
{
double t;
for (i = 0; i < s; i++)
for (j = 0; j < s; j++)
m_inv[i][j] = 0;
+
for (i = 0; i < s; i++)
m_inv[i][i] = 1;
}
t = 1 / tmp[i][i];
+
for (k = 0 ; k < s ; k++) {
tmp[k][i] *= t;
m_inv[k][i] *= t;
}
- for (j = 0 ; j < s ; j++) {
+ for (j = 0 ; j < s ; j++)
if (j != i) {
t = tmp[i][j];
for (k = 0 ; k < s; k++) {
m_inv[k][j] -= m_inv[k][i] * t;
}
}
- }
-
}
}
+
+
void multiply_scalar_inplace(int rows, int cols, double m[rows][cols], double scalar)
{
int i,j;
for (j = 0; j < cols; j++)
m[i][j] = m[i][j] * scalar;
}
+
+
void assign (int rows, int cols, double m[rows][cols], double m1[rows][cols])
{
int i,j;