Logo

NAG and Python

Return to Front

Contents:

  • Welcome
  • Changelog
  • Package Documentation
    • Package Summary
    • Subpackage Summary
    • Attributes
    • Algorithmic Contents
    • Interface Features
    • Documentation Structure
    • Performance Tips
    • Thread Safety Considerations
    • Porting to other NAG Libraries
    • Migrating from Earlier Releases of the NAG Library for Python
    • Numbering Scheme
    • Subpackages
      • library Subpackage
        • Package Summary
        • Subpackage Summary
        • Submodule Summary
        • Functionality Notes
        • Raises
        • Submodules
          • library.anova Submodule
          • library.blas Submodule
          • library.blast Submodule
          • library.blgm Submodule
          • library.complex Submodule
          • library.contab Submodule
          • library.correg Submodule
          • library.det Submodule
          • library.dot Submodule
          • library.eigen Submodule
          • library.fit Submodule
          • library.glopt Submodule
          • library.ieee Submodule
          • library.info Submodule
          • library.inteq Submodule
          • library.interp Submodule
          • library.lapackeig Submodule
          • library.lapacklin Submodule
          • library.linsys Submodule
          • library.machine Submodule
          • library.math Submodule
          • library.matop Submodule
          • library.mesh Submodule
          • library.mip Submodule
          • library.mv Submodule
          • library.nonpar Submodule
          • library.numdiff Submodule
          • library.ode Submodule
          • library.omp Submodule
          • library.opt Submodule
          • library.orthog Submodule
          • library.pde Submodule
          • library.quad Submodule
          • library.rand Submodule
          • library.rnla Submodule
          • library.roots Submodule
          • library.smooth Submodule
          • library.sort Submodule
          • library.sparseig Submodule
          • library.sparse Submodule
          • library.specfun Submodule
          • library.stat Submodule
          • library.sum Submodule
          • library.surviv Submodule
          • library.tsa Submodule
          • library.univar Submodule
          • library.wav Submodule
          • library.zeros Submodule
        • Subpackages
      • kusari Submodule
      • base Subpackage
  • Known Issues
  • Supplementary Info
  • Technical Support
  • Copyright
  • Terms and Conditions

Quick search

naginterfaces.library.sort.intvec_​search¶

naginterfaces.library.sort.intvec_search(valid, iv, item, m1=1)[source]¶

intvec_search searches an ordered vector of integer numbers and returns the index of the first value equal to the sought-after item.

For full information please refer to the NAG Library document for m01nb

https://www.nag.com/numeric/nl/nagdoc_29.2/flhtml/m01/m01nbf.html

Parameters
validbool

If valid is set to True argument checking will be performed. If valid is set to False intvec_search will be called without argument checking (which includes checking that array iv is sorted in ascending order) and the function will return with no exception or warning is raised. See Further Comments for further details.

ivint, array-like, shape (m2)

Elements m1−1 to m2−1 contain integer values to be searched.

itemint

The sought-after item.

m1int, optional

Note: this argument represents an array index; the value you supply must be base-1 for compatibility with the NAG Engine.

The index of the first element of iv to be searched.

Returns
iivint

Note: this argument represents an array index; the value returned will be base-1.

The index of the first value equal to the sought-after item.

Raises
NagValueError
(errno 2)

On entry, iv must be sorted in ascending order: iv element ⟨value⟩> element ⟨value⟩.

(errno 3)

On entry, m1=⟨value⟩.

Constraint: m1≥1.

(errno 4)

On entry, m1=⟨value⟩, m2=⟨value⟩.

Constraint: m1≤m2.

Notes

intvec_search is based on Professor Niklaus Wirth’s implementation of the Binary Search algorithm (see Wirth (2004)), but with two modifications. First, if the sought-after item is less than the value of the first element of the array to be searched, −1 is returned. Second, if a value equal to the sought-after item is not found, the index of the immediate lower value is returned.

References

Wirth, N, 2004, Algorithms and Data Structures, 35–36, Prentice Hall

© The Numerical Algorithms Group Limited, 2017-2023. | Powered by Sphinx 4.4.0 & Alabaster 0.7.12 | Page source