/************************************************************************* * * * Vega FEM Simulation Library Version 3.1 * * * * "matrix" library , Copyright (C) 2007 CMU, 2009 MIT * * All rights reserved. * * * * Code author: Jernej Barbic * * http://www.jernejbarbic.com/code * * Research: Jernej Barbic, Doug L. James, Jovan Popovic * * Funding: NSF, Link Foundation, Singapore-MIT GAMBIT Game Lab * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the BSD-style license that is * * included with this library in the file LICENSE.txt * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file * * LICENSE.TXT for more details. * * * *************************************************************************/ #include "matrixMacros.h" #include "matrixBLAS.h" #include template real * SumMatrices(int m, int n, real * mtx1, real * mtx2, real * output) { real * target = output; if (target == NULL) target = (real*) malloc (sizeof(real) * m * n); int mn = m * n; for(int i=0; i real * SubtractMatrices(int m, int n, real * mtx1, real * mtx2, real * output) { real * target = output; if (target == NULL) target = (real*) malloc (sizeof(real) * m * n); int mn = m * n; for(int i=0; i real * MultiplyMatrices(int m, int p, int n, real * mtx1, real * mtx2, real * output) { real * target = output; if (target == NULL) target = (real*) malloc (sizeof(real) * m * n); for(int i=0; i real * MultiplyMatricesT(int m, int p, int n, real * mtx1, real * mtx2, real * output) { real * target = output; if (target == NULL) target = (real*) malloc (sizeof(real) * m * n); for(int i=0; i real * ScalarMultiplyMatrix(int m, int n, real alpha, real * mtx, real * output) { real * target = output; if (target == NULL) target = (real*) malloc (sizeof(real) * m * n); int mn = m * n; for(int i=0; i real VectorNorm(int m, real * vec) { double norm = 0; for(int i=0; i