BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
fn_unique.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
18
19#ifndef BELFEM_FN_UNIQUE_HPP
20#define BELFEM_FN_UNIQUE_HPP
21
22#ifdef BELFEM_BLAZE
23#include <memory>
24#include <vector>
25#include <algorithm>
26#endif
27
28#include "cl_Vector.hpp"
29
30namespace belfem
31{
32//------------------------------------------------------------------------------
33
44 template < typename T >
45 void
46 unique( Vector< T > & aVector )
47 {
48#ifdef BELFEM_ARMADILLO
49 // call armadillo interface
50 aVector.vector_data() = unique( aVector.vector_data() );
51#elif BELFEM_BLAZE
52
53 // get length of vector
54 std::size_t tLength = aVector.length();
55
56 // get pointer to raw data
57 T * tData = aVector.data();
58
59 // sort data
60 std::sort( tData, tData + tLength );
61
62 // make vector unique and resize
63 aVector.vector_data().resize(
64 std::distance( tData,
65 std::unique( tData, tData + tLength ) ),
66 true );
67#endif
68 }
69
70//------------------------------------------------------------------------------
71}
72
73#endif //BELFEM_FN_UNIQUE_HPP
Column vector.
Definition cl_BZ_Vector.hpp:41
T * data()
expose the underlying raw pointer ( writable version )
Definition cl_AR_Vector.hpp:182
size_t length() const
get the length of the vector
Definition cl_AR_Vector.hpp:257
VectorType & vector_data()
expose the underlying matrix implementation ( writable version )
Definition cl_AR_Vector.hpp:204
USER GUIDES:
Definition cl_Capacitor.cpp:16
void unique(Cell< T > &aCell)
Definition cl_Cell.hpp:488