Perl CPL module object method not found

I am trying to use the CPAN module: Math::Vector::Real::Neighbors

I see the following error message:

Cannot find method of object "field" via package "Math :: Vector :: Real" in / usr / local / share / perl / 5.14.2 / Math / Vector / Real / Neighbors.pm line 12.

So, I go to the package and see this: my ($bottom, $top) = Math::Vector::Real->box(@_);

Then I go to the package Real.pm

at:/usr/local/share/perl/5.14.2/Math/Vector/Real.pm

I can see that there is a box routine in it: sub box {...

Any idea why the error might be occurring?

+3


source to share


2 answers


You need to add use Math::Vector::Real

to the beginning of your script to get Math :: Vector :: Real :: Neighbors working. The following code works as expected:

use strict;
use warnings;

use Math::Vector::Real;
use Math::Vector::Real::Neighbors;
use Math::Vector::Real::Random;

my @v = map Math::Vector::Real->random_normal(2), 0..1000;
my @nearest_ixs = Math::Vector::Real::Neighbors->neighbors(@v);

      



But note that it didn't work without a string using Math :: Vector :: Real .

+7


source


I am the author of the Math :: Vector :: Real family of Perl modules.

Currently, to find neighbors for a set of points, the algorithm presented in Math :: Vector :: Real :: kdTree is much better:



my @v = ...;
my $kdtree = Math::Vector::Real::kdTree->new(@v);
my @nearest_ixs = $kdtree->find_nearest_vector_all_internal;

      

+2


source







All Articles