Skip to content

Yurie/Index

A Mathematica package for coding a indexed variable into a single symbol.

The GitHub repository is yuriever/Yurie-Index.

Designing idea

This package provides the functionality of coding/decoding a variable indexed by label and script into/from a single symbol. For example, "x"<>"dagger"<>"0" will be coded as xdagger0 and formatted as \(x^{\dagger}_{0}\).

_Subsuperscript <=> "variable"<>"label"<>"script" <=> _Symbol

The system function pair ToExpression, ToString is non-invertible at Null, and to override this we introduce the public function toString.

The kernel functions will convert symbols to strings, use string pattern matching, and finally convert back to symbols if necessary.

Functionalities

Helper functions

  • toString - map Null to empty string.

Kernel functions

  • indexize - indexify a list of variables.

  • indexify - indexify the specified variables in an expression.

    Default options:

    • Heads->False - head variables will not be indexified. This option is inherited from Replace.

    • Transpose->False - Lacia-Breakpoint-2023-11-22-11:45

  • indexArray - generate tensor of symbols by Array.

    indexArray[{2}]@x
    
    indexArray[{2,2}]@x
    
    Out[]= {x1,x2}
    
    Out[]= {{x11,x12},{x21,x22}}
    
  • indexPolynomial - generate multi-variable polynomials by indexArray.

    indexPolynomial[{2},{0}][a][x]
    
    indexPolynomial[{2,2},{0,0}][a][x,y]
    
    Out[]= a0+a1 x
    
    Out[]= a00+a10 x+a01 y+a11 x y
    
  • indexSplit - split Symbol|String into variable + (label +) index.