Ca.Pranavpatel.Algo.Kombin 1.0.3

dotnet add package Ca.Pranavpatel.Algo.Kombin --version 1.0.3
                    
NuGet\Install-Package Ca.Pranavpatel.Algo.Kombin -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ca.Pranavpatel.Algo.Kombin" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ca.Pranavpatel.Algo.Kombin" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Ca.Pranavpatel.Algo.Kombin" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ca.Pranavpatel.Algo.Kombin --version 1.0.3
                    
#r "nuget: Ca.Pranavpatel.Algo.Kombin, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ca.Pranavpatel.Algo.Kombin@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ca.Pranavpatel.Algo.Kombin&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Ca.Pranavpatel.Algo.Kombin&version=1.0.3
                    
Install as a Cake Tool

KombiN - .NET Library

KombiN is a library for bijectively mapping all ordered pairs $(a_i, b_j)$ from two finite sets A and B into a single linear index. KombiN orders pairs by ascending weight (sum of indices) using a three-region zig-zag algorithm, enabling O(1) bidirectional lookups.


Installation

Install from NuGet:

dotnet add package Ca.Pranavpatel.Algo.Kombin

Usage

Suppose set A has 100 elements and set B has 80 elements, both using zero-based indexing:

using Ca.Pranavpatel.Algo.Kombin;

// Initialize Table for sets A (100 elements) and B (80 elements), zero-based indexing
Table myObj = new Table(100, 80, true);

// Get index for combination pair (ai: 46, bi: 72)
long index = myObj.GetIndexOfElements(46, 72);

// Get combination pair from index value
long ai, bi;
(ai, bi) = myObj.GetElementsAtIndex(index);

API Reference

Table Class

Constructor:

Table(long lengthOfA, long lengthOfB, bool zeroBasedIndex)
  • lengthOfA: Number of elements in set A.
  • lengthOfB: Number of elements in set B.
  • zeroBasedIndex: true for zero-based, false for one-based indexing.

Methods:

  • long GetIndexOfElements(long ai, long bi)
    Returns the unique index for the pair (ai, bi).

  • (long, long) GetElementsAtIndex(long index)
    Returns the pair (ai, bi) for the given index.


Example: Enumerate All Pairs by Weight

var table = new Table(3, 3, false);
for (long i = 1; i <= 9; i++)
{
    var (ai, bi) = table.GetElementsAtIndex(i);
    Console.WriteLine($"{i}: ({ai}, {bi})");
}

Edge Cases & Error Handling

  • Throws ArgumentOutOfRangeException for invalid indices or set sizes.
  • Throws OverflowException if arithmetic overflows.

License

MIT License.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Ca.Pranavpatel.Algo.Kombin:

Package Downloads
Ca.Pranavpatel.Algo.GridPointCode

Grid Point Code (GPC) is a global geocoding system that provides a unique, lossless, and compact alphanumeric code for any geographic location (home, office, or other places). It enables precise identification and offline conversion between geographic coordinates and codes.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 84 7/11/2025
1.0.2 393 10/26/2023