Debian Codegraph @

tools/physicalModeling/mesh2faust/vega/libraries/sparseMatrix/sparseMatrixMT.cpp

raw symbols SCIP
1 /*************************************************************************
2 * *
3 * Vega FEM Simulation Library Version 3.1 *
4 * *
5 * "sparseMatrixMT" library , Copyright (C) 2007 CMU, 2009 MIT, 2016 USC *
6 * All rights reserved. *
7 * *
8 * Code author: Jernej Barbic *
9 * http://www.jernejbarbic.com/code *
10 * *
11 * Research: Jernej Barbic, Fun Shing Sin, Daniel Schroeder, *
12 * Doug L. James, Jovan Popovic *
13 * *
14 * Funding: National Science Foundation, Link Foundation, *
15 * Singapore-MIT GAMBIT Game Lab, *
16 * Zumberge Research and Innovation Fund at USC *
17 * *
18 * This library is free software; you can redistribute it and/or *
19 * modify it under the terms of the BSD-style license that is *
20 * included with this library in the file LICENSE.txt *
21 * *
22 * This library is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file *
25 * LICENSE.TXT for more details. *
26 * *
27 *************************************************************************/
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <math.h>
33 #include <set>
34 #include <algorithm>
35 #include "sparseMatrixMT.h"
36 using namespace std;
37
38 // for faster computation, enable the -fopenmp -DUSE_OPENMP macro line in the Makefile-header file (see also documentation)
39
40 #ifdef USE_OPENMP
41 #include <omp.h>
42 #endif
43
44 void SparseMatrixMT::MultiplyVector(const SparseMatrix * A, const double * input, double * result, int numThreads)
45 {
46 int ** indices = A->GetColumnIndices();
47 double ** entries = A->GetEntries();
48 int * rowLengths = A->GetRowLengths();
49 int n = A->GetNumRows();
50 if (numThreads < 0)
51 #ifdef USE_OPENMP
52 numThreads = omp_get_num_threads();
53 #else
54 numThreads = 0;
55 #endif
56
57 #ifdef USE_OPENMP
58 #pragma omp parallel for num_threads(numThreads)
59 #endif
60 for(int i=0; i<n; i++)
61 {
62 result[i] = 0;
63 for(int j=0; j < rowLengths[i]; j++)
64 {
65 result[i] += input[indices[i][j]] * entries[i][j];
66 }
67 }
68 }
69
70