modN

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 3.9, Creation date: 2017-06-04, Last change: 2025-09-14

returns mod fnct for elements N:N+k(-1)

Description

auxiliary function for array manipulation. Instead of return values between [0..k-1], this function returns [N..N+k-1] by a=mod(n-N,k)+N
rare function used in CVLdimclassifier


See Also: mod1

Example Illustration

 missing image of modN(n,k,N)

Syntax

a=modN(n,k,[N])

Input Parameter

n: number
k: divider
N: Interval start

Output Parameter

a: rest

Examples


modN(1:6,3)
modN(1:6,3,2)
k=16:24 % startindices from 16 to 24 in a row list
k1=modN(k+1,numel(k),k(1)) % creates the lost if the following points23




Copyright 2017-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, modN, is an auxiliary procedure for array manipulation. It is designed to return values within a specified interval rather than the default range provided by the standard modulus operation.

Input Parameters

Output

Algorithm Explanation

The function modN is defined to adjust the standard modulus operation. Instead of returning values between [0..k-1], it returns values within the interval [N..N+k-1]. This is achieved by the formula:

a = mod(n-N, k) + N;

Here's a step-by-step explanation:

  1. Subtract N from n to shift the range of n to start from zero.
  2. Apply the modulus operation with k to get the remainder.
  3. Add N back to shift the result into the desired interval [N..N+k-1].

Example Usage

Here are some examples to illustrate the function's behavior:

This function is particularly useful in scenarios where a custom interval is needed for modulus operations, such as in certain classification tasks.

Algorithm explaination created using ChatGPT on 2025-08-18 23:22. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21