Kdtree_Create
Create the actual tree structure by giving an input array of data.
note
Input data is input_data(1:d,1:N)
, NOT the other way around.
Optional arguments: If 'dim' is specified, then the tree will only search the first 'dim' components of input_data, otherwise, dim is inferred from SIZE(input_data,1)
.
If sort
is true then output results will be sorted by increasing distance. The default is false, as it is faster to not sort.
If rearrange
is true then an internal copy of the data, rearranged by terminal node, will be made for cache friendliness. The default is true, as it speeds searches, but building takes longer, and extra memory is used.
Interface
- Interface
- example
- ↢ close
FUNCTION Kdtree2_create(input_data, dim, sort, rearrange) RESULT(mr)
TYPE(Kdtree2_), POINTER :: mr
INTEGER, INTENT(IN), OPTIONAL :: dim
LOGICAL, INTENT(IN), OPTIONAL :: sort
LOGICAL, INTENT(IN), OPTIONAL :: rearrange
REAL(kdkind), TARGET :: input_data(:, :)
END FUNCTION
PROGRAM main
USE easifemBase
USE Kdtree2_Module
IMPLICIT NONE
TYPE(kdtree2), POINTER :: kd
REAL(DFP), ALLOCATABLE :: input_data(:, :)
! FUNCTION kdtree2_create(input_data, dim, sort, rearrange) RESULT(mr)
CALL Reallocate(input_data, 3, 100)
CALL RANDOM_NUMBER(input_data)
kd => kdtree2_create(input_data, sort=.TRUE., rearrange=.TRUE.)
! CALL kdtree2_destroy(kd)
END PROGRAM main