svMultiPhysics
Loading...
Searching...
No Matches
utils.h
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others.
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef UTILS_H
5#define UTILS_H
6
7#include "Array.h"
8
9namespace utils {
10
12{
13 public:
14 /// Maximum length of the stack
15 int maxN = 0;
16
17 /// Current size of stack
18 int n = 0;
19
20 /// Values inside stack
22};
23
25{
26 public:
27 int n = 0;
28 int maxN = 0;
30};
31
32
33bool btest(int value, int pos);
34
35int CountBits(int n);
36
37double cput();
38
39Vector<double> cross(const Array<double>& V);
40
41bool dequeue(queueType& que, int& iVal);
42void enqueue(queueType& que, int iVal);
43
44int ibclr(int value, int pos);
45int ibset(int value, int pos);
46bool is_zero(double value1, double value2=0.0);
47
48double mem_usage(const bool print_usage=false, const std::string& prefix="");
49
50double norm(const Vector<double>& U);
51double norm(const Vector<double>& U, const Vector<double>& V);
52double norm(const Array<double>& U);
53
54void print_mem(const std::string& type, const std::string& prefix, const double memory_in_use, const double memory_returned);
55void print_stats(const std::string& type, const std::string& prefix, const int allocated, const int active);
56
57bool pull_stack(stackType& stk, int& iVal);
58void push_stack(stackType& stk, int iVal);
59void push_stack(stackType& stk, std::initializer_list<int> values);
60
61int sign(double value);
62
63void swap(int& value1, int& value2);
64
65void find_loc(const Array<int>& array, int value, std::array<int, 2>& ind);
66
67};
68
69#endif
70
The Vector template class is used for storing int and double data.
Definition Vector.h:23
Definition utils.h:25
Definition utils.h:12
int maxN
Maximum length of the stack.
Definition utils.h:15
int n
Current size of stack.
Definition utils.h:18
Vector< int > v
Values inside stack.
Definition utils.h:21