Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Cabieces
otb
Commits
77895c20
Commit
77895c20
authored
10 years ago
by
Christophe Palmann
Browse files
Options
Downloads
Patches
Plain Diff
ENH: bandmathx (operators)
parent
c60cb20a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Code/Common/otbParserX.cxx
+1
-0
1 addition, 0 deletions
Code/Common/otbParserX.cxx
Code/Common/otbParserXPlugins.cxx
+60
-2
60 additions, 2 deletions
Code/Common/otbParserXPlugins.cxx
Code/Common/otbParserXPlugins.h
+21
-1
21 additions, 1 deletion
Code/Common/otbParserXPlugins.h
with
82 additions
and
3 deletions
Code/Common/otbParserX.cxx
+
1
−
0
View file @
77895c20
...
...
@@ -63,6 +63,7 @@ public:
m_MuParserX
.
DefineFun
(
new
cat
);
m_MuParserX
.
DefineOprt
(
new
ElementWiseDivision
);
m_MuParserX
.
DefineOprt
(
new
ElementWiseMultiplication
);
m_MuParserX
.
DefineOprt
(
new
ElementWisePower
);
m_MuParserX
.
DefineFun
(
new
mean
);
m_MuParserX
.
DefineFun
(
new
var
);
m_MuParserX
.
DefineFun
(
new
median
);
...
...
This diff is collapsed.
Click to expand it.
Code/Common/otbParserXPlugins.cxx
+
60
−
2
View file @
77895c20
...
...
@@ -30,6 +30,7 @@ void bands::Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_
{
assert
(
a_iArgc
==
2
);
assert
(
a_pArg
[
0
]
->
GetType
()
==
'm'
);
assert
(
a_pArg
[
1
]
->
GetType
()
==
'm'
);
// Get the argument from the argument input vector
...
...
@@ -53,6 +54,8 @@ void bands::Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_
void
conv
::
Eval
(
mup
::
ptr_val_type
&
ret
,
const
mup
::
ptr_val_type
*
a_pArg
,
int
a_iArgc
)
{
assert
(
a_pArg
[
0
]
->
GetType
()
==
'm'
);
// Get the argument from the argument input vector
mup
::
matrix_type
m1
=
a_pArg
[
0
]
->
GetArray
();
...
...
@@ -95,6 +98,9 @@ void conv::Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_i
void
ElementWiseDivision
::
Eval
(
mup
::
ptr_val_type
&
ret
,
const
mup
::
ptr_val_type
*
a_pArg
,
int
)
{
assert
(
a_pArg
[
0
]
->
GetType
()
==
'm'
);
assert
(
a_pArg
[
1
]
->
GetType
()
==
'm'
);
const
mup
::
matrix_type
a
=
a_pArg
[
0
]
->
GetArray
();
const
mup
::
matrix_type
b
=
a_pArg
[
1
]
->
GetArray
();
...
...
@@ -102,6 +108,17 @@ void ElementWiseDivision::Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *
int
nbrows
=
a
.
GetRows
();
int
nbcols
=
a
.
GetCols
();
int
nbrows2
=
b
.
GetRows
();
int
nbcols2
=
b
.
GetCols
();
if
(
(
nbrows
!=
nbrows2
)
||
(
nbcols
!=
nbcols2
)
)
{
mup
::
ErrorContext
err
;
err
.
Errc
=
mup
::
ecMATRIX_DIMENSION_MISMATCH
;
err
.
Ident
=
GetIdent
();
throw
mup
::
ParserError
(
err
);
}
mup
::
matrix_type
res
(
nbrows
,
nbcols
,
0.
);
for
(
int
k
=
0
;
k
<
nbcols
;
++
k
)
...
...
@@ -119,12 +136,27 @@ void ElementWiseDivision::Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *
void
ElementWiseMultiplication
::
Eval
(
mup
::
ptr_val_type
&
ret
,
const
mup
::
ptr_val_type
*
a_pArg
,
int
)
{
assert
(
a_pArg
[
0
]
->
GetType
()
==
'm'
);
assert
(
a_pArg
[
1
]
->
GetType
()
==
'm'
);
const
mup
::
matrix_type
a
=
a_pArg
[
0
]
->
GetArray
();
const
mup
::
matrix_type
b
=
a_pArg
[
1
]
->
GetArray
();
int
nbrows
=
a
.
GetRows
();
int
nbcols
=
a
.
GetCols
();
int
nbrows2
=
b
.
GetRows
();
int
nbcols2
=
b
.
GetCols
();
if
(
(
nbrows
!=
nbrows2
)
||
(
nbcols
!=
nbcols2
)
)
{
mup
::
ErrorContext
err
;
err
.
Errc
=
mup
::
ecMATRIX_DIMENSION_MISMATCH
;
err
.
Ident
=
GetIdent
();
throw
mup
::
ParserError
(
err
);
}
mup
::
matrix_type
res
(
nbrows
,
nbcols
,
0.
);
for
(
int
k
=
0
;
k
<
nbcols
;
++
k
)
...
...
@@ -136,11 +168,37 @@ void ElementWiseMultiplication::Eval(mup::ptr_val_type &ret, const mup::ptr_val_
}
void
ElementWisePower
::
Eval
(
mup
::
ptr_val_type
&
ret
,
const
mup
::
ptr_val_type
*
a_pArg
,
int
a_iArgc
)
{
assert
(
a_iArgc
==
2
);
assert
(
a_pArg
[
0
]
->
GetType
()
==
'm'
);
// Get the argument from the argument input vector
const
mup
::
matrix_type
a
=
a_pArg
[
0
]
->
GetArray
();
const
double
pw
=
a_pArg
[
1
]
->
GetFloat
();
int
nbrows
=
a
.
GetRows
();
int
nbcols
=
a
.
GetCols
();
mup
::
matrix_type
res
(
nbrows
,
nbcols
,
0.
);
for
(
int
k
=
0
;
k
<
nbcols
;
++
k
)
for
(
int
p
=
0
;
p
<
nbrows
;
++
p
)
{
assert
(
a
.
At
(
p
,
k
).
GetFloat
()
>=
0
);
res
.
At
(
p
,
k
)
=
vcl_pow
(
a
.
At
(
p
,
k
).
GetFloat
(),
pw
);
}
// The return value is passed by writing it to the reference ret
*
ret
=
res
;
}
void
ndvi
::
Eval
(
mup
::
ptr_val_type
&
ret
,
const
mup
::
ptr_val_type
*
a_pArg
,
int
a_iArgc
)
{
// Get the argument from the argument input vector
mup
::
float_type
r
=
a_pArg
[
0
]
->
GetFloat
();
mup
::
float_type
niri
=
a_pArg
[
1
]
->
GetFloat
();
...
...
@@ -475,6 +533,7 @@ void vmax::Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_i
}
//--------------------------------------------------------------------------------------------------------//
void
vcos
::
Eval
(
mup
::
ptr_val_type
&
ret
,
const
mup
::
ptr_val_type
*
a_pArg
,
int
a_iArgc
)
{
...
...
@@ -699,6 +758,5 @@ void vsqrt::Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_
*
ret
=
res
;
}
}
//end namespace otb
This diff is collapsed.
Click to expand it.
Code/Common/otbParserXPlugins.h
+
21
−
1
View file @
77895c20
...
...
@@ -107,6 +107,26 @@ class ElementWiseMultiplication : public mup::IOprtBin
};
class
ElementWisePower
:
public
mup
::
IOprtBin
{
public:
ElementWisePower
()
:
IOprtBin
(
_T
(
"pow"
),
(
int
)
mup
::
prPOW
,
mup
::
oaRIGHT
)
{}
virtual
void
Eval
(
mup
::
ptr_val_type
&
ret
,
const
mup
::
ptr_val_type
*
a_pArg
,
int
a_iArgc
);
const
mup
::
char_type
*
GetDesc
()
const
{
return
_T
(
"pow - Power for noncomplex vectors & matrices"
);
}
virtual
mup
::
IToken
*
Clone
()
const
{
return
new
ElementWisePower
(
*
this
);
}
};
class
ndvi
:
public
mup
::
ICallback
{
public:
...
...
@@ -246,7 +266,6 @@ public:
}
};
//--------------------------------------------------------------------------------------------------------//
class
vcos
:
public
mup
::
ICallback
{
...
...
@@ -467,6 +486,7 @@ public:
}
};
}
//end namespace otb
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment