The unchecked module "find_disjoint_interval_" of the Mastrave modelling library

Daniele de Rigo

The file find_disjoint_interval_.m is part of Mastrave.

Mastrave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Mastrave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Mastrave. If not, see http://www.gnu.org/licenses/.

Function declaration

[interval_idx, value_idx] = find_disjoint_interval_( disjoint_intervals ,
values             ,
inclusion          )



Description

Warning: find_disjoint_interval_ should not be used in end-user code because it deliberately skips input and output arguments checks and other pre- and post-condition testing. End-user code should use instead the find_disjoint_interval function (without the ending underscore).

Given the vectors a and b with the same size and satisfying the following conditions:
all( a < b )
all( a == sort(a) )
all( b == sort(b) )
all( b(1:end-1) <= a(2:end) )
disjoint_intervals = [ a b ] find_disjoint_interval_ finds the index i of a and b and the index j of another vector values such that

a(i) <= values(j) < b(i)

if inclusion == '[)', otherwise

a(i) < values(j) <= b(i)

if inclusion == '(]' .

The sets of indexes i and j are returned respectively in the vectors interval_idx and value_idx .

Input arguments


disjoint_intervals     ::matrix,real::
2-columns matrix of non-overlapping real
intervals sorted in ascending order

values                 ::real::
vector or matrix of values for which determine
to which interval each of them belong

inclusion              ::string::
set which interval border check has to be
performed.
Valid options are:

option    │      meaning
─────────────┼────────────────────────────────
'[)'       │ a(i) <= values(j) <  b(i)
─────────────┼────────────────────────────────
'(]'       │ a(i) <  values(j) <= b(i)



Example of usage

See also:
create_contiguous_intervals

Keywords:
intervals, keys, indexes

version: 0.6.5

Support

The Mastrave modelling library is committed to provide reusable and general - but also robust and scalable - modules for research modellers dealing with computational science.  You can help the Mastrave project by providing feedbacks on unexpected behaviours of this module.  Despite all efforts, all of us - either developers or users - (should) know that errors are unavoidable.  However, the free software paradigm successfully highlights that scientific knowledge freedom also implies an impressive opportunity for collectively evolve the tools and ideas upon which our daily work is based.  Reporting a problem that you found using Mastrave may help the developer team to find a possible bug.  Please, be aware that Mastrave is entirely based on voluntary efforts: in order for your help to be as effective as possible, please read carefully the section on reporting problems.  Thank you for your collaboration.

Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Daniele de Rigo