| 1 | /************************************************************************* |
| 2 | * * |
| 3 | * Vega FEM Simulation Library Version 3.1 * |
| 4 | * * |
| 5 | * "matrix" library , Copyright (C) 2007 CMU, 2009 MIT * |
| 6 | * All rights reserved. * |
| 7 | * * |
| 8 | * Code author: Jernej Barbic * |
| 9 | * http://www.jernejbarbic.com/code * |
| 10 | * Research: Jernej Barbic, Doug L. James, Jovan Popovic * |
| 11 | * Funding: NSF, Link Foundation, Singapore-MIT GAMBIT Game Lab * |
| 12 | * * |
| 13 | * This library is free software; you can redistribute it and/or * |
| 14 | * modify it under the terms of the BSD-style license that is * |
| 15 | * included with this library in the file LICENSE.txt * |
| 16 | * * |
| 17 | * This library is distributed in the hope that it will be useful, * |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file * |
| 20 | * LICENSE.TXT for more details. * |
| 21 | * * |
| 22 | *************************************************************************/ |
| 23 | |
| 24 | #ifndef _MATRIXPROJECTION_H_ |
| 25 | #define _MATRIXPROJECTION_H_ |
| 26 | |
| 27 | /* |
| 28 | These routines allow you to multiply a matrix with a vector, |
| 29 | and project a vector onto a space spanned by an orthogonal matrix. |
| 30 | They require a BLAS implementation for your system. |
| 31 | |
| 32 | See also matrixIO.h. |
| 33 | */ |
| 34 | |
| 35 | // construct vector f, using the equation f = U q |
| 36 | // matrix U is of size n x r |
| 37 | template <class real> |
| 38 | void SynthesizeVector(int n, int r, real * U, real * q, real * f); |
| 39 | |
| 40 | // construct sparse vector f, using the equation f = U q |
| 41 | // matrix U is of size n x r, and is given in the column-major order |
| 42 | // vector q is of length r |
| 43 | // the coordinates of the vector f of interest are specified in the array i_buffer |
| 44 | // k is the total number of requested coordinates |
| 45 | // result is written into vector f. Length of result is k <= n |
| 46 | template <class real> |
| 47 | void SynthesizeSparseVector(int n, int r, real * U, real * q, real * f, int * i_buffer, int k); |
| 48 | |
| 49 | // project vector f onto basis, given by U, using the equation q = U^T f |
| 50 | // matrix U is of size n x r |
| 51 | template <class real> |
| 52 | void ProjectVector(int n, int r, real * U, real * q, real * f); |
| 53 | |
| 54 | // project sparse vector f onto basis, given by U, using the equation q = U^T f |
| 55 | // matrix U is of size n x r |
| 56 | // number of non-zero components of f is given by k |
| 57 | // non-zero components of vector f are given by f_buffer and i_buffer, where i_buffer[j] specifies the position, |
| 58 | // and f_buffer[j] specifies the force component at i_buffer[j] |
| 59 | template <class real> |
| 60 | void ProjectSparseVector(int n, int r, real * U, real * q, real * f_buffer, int * i_buffer, int k); |
| 61 | |
| 62 | #endif |
| 63 |