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
<PackageReference Include="Ca.Pranavpatel.Algo.Kombin" Version="1.0.3" />
<PackageVersion Include="Ca.Pranavpatel.Algo.Kombin" Version="1.0.3" />
<PackageReference Include="Ca.Pranavpatel.Algo.Kombin" />
paket add Ca.Pranavpatel.Algo.Kombin --version 1.0.3
#r "nuget: Ca.Pranavpatel.Algo.Kombin, 1.0.3"
#:package Ca.Pranavpatel.Algo.Kombin@1.0.3
#addin nuget:?package=Ca.Pranavpatel.Algo.Kombin&version=1.0.3
#tool nuget:?package=Ca.Pranavpatel.Algo.Kombin&version=1.0.3
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 | Versions 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. |
-
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.