Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
David Cazier
CGoGN
Commits
8ad45a03
Commit
8ad45a03
authored
Oct 16, 2012
by
Kenneth Vanhoey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tensor features
parent
6b553f26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
11 deletions
+36
-11
include/Geometry/tensor.h
include/Geometry/tensor.h
+9
-0
include/Geometry/tensor.hpp
include/Geometry/tensor.hpp
+27
-11
No files found.
include/Geometry/tensor.h
View file @
8ad45a03
...
...
@@ -107,6 +107,15 @@ class Tensor
*/
void
identity
()
;
/**
* \brief Modifier: set constant values
*
* Sets all values to r
*
* \param r the constant value
*/
void
setConst
(
const
REAL
&
r
)
;
/**
* \brief Modifier: copy Tensor
*
...
...
include/Geometry/tensor.hpp
View file @
8ad45a03
...
...
@@ -39,6 +39,9 @@ Tensor<SIZE, REAL>::Tensor(const Tensor& T):
m_order
(
T
.
m_order
)
{
m_data
=
new
REAL
[
T
.
nbElem
()]
;
for
(
unsigned
int
i
=
0
;
i
<
T
.
nbElem
()
;
++
i
)
m_data
[
i
]
=
T
[
i
]
;
}
template
<
unsigned
int
SIZE
,
typename
REAL
>
...
...
@@ -65,24 +68,37 @@ void Tensor<SIZE, REAL>::identity()
template
<
unsigned
int
SIZE
,
typename
REAL
>
void
Tensor
<
SIZE
,
REAL
>::
operator
=
(
const
Tensor
&
T
)
Tensor
<
SIZE
,
REAL
>::
zero
(
)
{
m_order
=
T
.
m_order
;
m_data
=
new
REAL
[
T
.
nbElem
()]
;
for
(
unsigned
int
i
=
0
;
i
<
T
.
nbElem
()
;
++
i
)
m_data
[
i
]
=
T
[
i
]
;
for
(
unsigned
int
i
=
0
;
i
<
(
unsigned
int
)
pow
(
SIZE
,
m_order
)
;
++
i
)
{
m_data
[
i
]
=
0
;
}
}
template
<
unsigned
int
SIZE
,
typename
REAL
>
void
Tensor
<
SIZE
,
REAL
>::
zero
(
)
Tensor
<
SIZE
,
REAL
>::
setConst
(
const
REAL
&
r
)
{
for
(
unsigned
int
i
=
0
;
i
<
(
unsigned
int
)
pow
(
SIZE
,
m_order
)
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
nbElem
(
)
;
++
i
)
{
m_data
[
i
]
=
0
;
m_data
[
i
]
=
r
;
}
}
template
<
unsigned
int
SIZE
,
typename
REAL
>
void
Tensor
<
SIZE
,
REAL
>::
operator
=
(
const
Tensor
&
T
)
{
m_order
=
T
.
m_order
;
delete
(
m_data
)
;
m_data
=
new
REAL
[
T
.
nbElem
()]
;
for
(
unsigned
int
i
=
0
;
i
<
T
.
nbElem
()
;
++
i
)
m_data
[
i
]
=
T
[
i
]
;
}
template
<
unsigned
int
SIZE
,
typename
REAL
>
const
REAL
&
Tensor
<
SIZE
,
REAL
>::
operator
()(
std
::
vector
<
unsigned
int
>
p
)
const
...
...
@@ -153,13 +169,13 @@ template <unsigned int SIZE, typename REAL>
bool
Tensor
<
SIZE
,
REAL
>::
incremIndex
(
std
::
vector
<
unsigned
int
>&
p
)
{
unsigned
int
i
=
0
;
while
(
i
<
p
.
size
()
)
int
i
=
p
.
size
()
-
1
;
while
(
i
>=
0
)
{
p
[
i
]
=
(
p
[
i
]
+
1
)
%
SIZE
;
if
(
p
[
i
]
!=
0
)
// if no overflow
return
true
;
++
i
;
--
i
;
}
return
false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment