indexvariant

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 5.3, Creation date: 2023-03-21, Last change: 2025-09-15

creates multidimensional index sequences for testing or other purposes

Description

much faster than permutevector - for different input vectors use permutevarargin

See Also: permutevector

Example Illustration

 missing image of indexvariant(vec,dim)

Syntax

zz=indexvariant([vec,dim])

Input Parameter

vec: row or col vector; default is [1 2 3]
dim: integer as dimension; default is 2

Output Parameter

zz: index field [numel(vec)^dim x dim]

Examples


zz=indexvariant([1:3],1); zz, whos zz
zz=indexvariant([1:3],2); zz, whos zz
zz=indexvariant([1:3],3); zz, whos zz
zz=indexvariant([1:3],4); zz, whos zz




Copyright 2023-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, indexvariant, generates multidimensional index sequences. It is designed to be faster than permutevector and is part of the SolidGeometry library.

Input Parameters

Output

Algorithm Steps

  1. Retrieve the input parameters vec and dim using the getfuncparams function. If not provided, use default values.
  2. Adjust dim by subtracting 1 to align with zero-based indexing.
  3. If vec is a row vector, transpose it to a column vector.
  4. Initialize zz with vec.
  5. Iterate from 1 to dim:

Example Usage

Examples of how to use the function:

Algorithm explaination created using ChatGPT on 2025-08-19 00:49. (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