mirror of
https://github.com/Relintai/pmlpp.git
synced 2024-12-21 14:56:47 +01:00
Added max_element_index, and min_element_index helper methods to Vector.
This commit is contained in:
parent
8c15b12f6a
commit
6e4dea3670
@ -1083,6 +1083,24 @@ real_t MLPPVector::max_element() const {
|
||||
|
||||
return max_element;
|
||||
}
|
||||
int MLPPVector::max_element_index() const {
|
||||
const real_t *aa = ptr();
|
||||
|
||||
real_t max_element = -Math_INF;
|
||||
int index = -1;
|
||||
|
||||
for (int i = 0; i < _size; i++) {
|
||||
real_t current_element = aa[i];
|
||||
|
||||
if (current_element > max_element) {
|
||||
max_element = current_element;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
real_t MLPPVector::min_element() const {
|
||||
const real_t *aa = ptr();
|
||||
|
||||
@ -1098,6 +1116,23 @@ real_t MLPPVector::min_element() const {
|
||||
|
||||
return min_element;
|
||||
}
|
||||
int MLPPVector::min_element_index() const {
|
||||
const real_t *aa = ptr();
|
||||
|
||||
real_t min_element = Math_INF;
|
||||
int index = -1;
|
||||
|
||||
for (int i = 0; i < _size; i++) {
|
||||
real_t current_element = aa[i];
|
||||
|
||||
if (current_element > min_element) {
|
||||
min_element = current_element;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -1467,7 +1502,10 @@ void MLPPVector::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("maxvb", "a", "b"), &MLPPVector::maxvb);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("max_element"), &MLPPVector::max_element);
|
||||
ClassDB::bind_method(D_METHOD("max_element_index"), &MLPPVector::max_element_index);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("min_element"), &MLPPVector::min_element);
|
||||
ClassDB::bind_method(D_METHOD("min_element_index"), &MLPPVector::min_element_index);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("euclidean_distance", "b"), &MLPPVector::euclidean_distance);
|
||||
ClassDB::bind_method(D_METHOD("euclidean_distance_squared", "b"), &MLPPVector::euclidean_distance_squared);
|
||||
|
@ -194,7 +194,10 @@ public:
|
||||
void maxvb(const Ref<MLPPVector> &a, const Ref<MLPPVector> &b);
|
||||
|
||||
real_t max_element() const;
|
||||
int max_element_index() const;
|
||||
|
||||
real_t min_element() const;
|
||||
int min_element_index() const;
|
||||
|
||||
//std::vector<real_t> round(std::vector<real_t> a);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user