BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
fn_BZ_linspace.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
12#ifndef BELFEM_FN_BZ_LINSPACE_HPP
13#define BELFEM_FN_BZ_LINSPACE_HPP
14
15#include "cl_BZ_Vector.hpp"
16
17namespace belfem
18{
19//------------------------------------------------------------------------------
20
21 template< typename T >
22 void
23 linspace( const T & aStart,
24 const T & aEnd,
25 const belfem::size_t & aN,
26 Vector <T> & aValues )
27 {
28 // yes, this can be done a lot better using std::for_each
29
30 aValues.set_size( aN );
31
32 belfem::size_t tN = aN - 1;
33
34 // stepsize
35 T tDX = ( aEnd - aStart ) / ( aN - 1 );
36
37 // first step
38 aValues( 0 ) = aStart;
39
40 // intermediate steps
41 for ( uint k = 1; k < tN; ++k )
42 {
43 aValues( k ) = aValues( k - 1 ) + tDX;
44 }
45
46 // last step
47 aValues( tN ) = aEnd;
48 }
49
50//------------------------------------------------------------------------------
51
52 template< typename T >
53 Vector <T>
54 linspace( const T & aStart,
55 const T & aEnd,
56 const belfem::size_t & aN )
57 {
58 Vector <T> aValues;
59 linspace( aStart, aEnd, aN, aValues );
60 return aValues;
61 }
62
63//------------------------------------------------------------------------------
64
65}
66#endif //BELFEM_FN_BZ_LINSPACE_HPP
USER GUIDES:
Definition cl_Capacitor.cpp:16
@ T
Definition cl_Material.hpp:122
unsigned int uint
Definition typedefs.hpp:30
size_t size_t
Definition typedefs.hpp:25
void linspace(const T &aStart, const T &aEnd, const belfem::size_t &aN, Vector< T > &aValues)
Definition fn_AR_linspace.hpp:22