adnus 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of adnus might be problematic. Click here for more details.

adnus/__init__.py CHANGED
@@ -15,7 +15,20 @@ from .main import (
15
15
  HyperrealNumber,
16
16
  oresme_sequence,
17
17
  harmonic_numbers,
18
- binet_formula
18
+ binet_formula,
19
+ generate_cayley_dickson_number,
20
+ generate_cd_chain,
21
+ reals,
22
+ Complex,
23
+ Quaternion,
24
+ Octonion,
25
+ Sedenion,
26
+ Pathion,
27
+ Chingon,
28
+ Routon,
29
+ Voudon,
30
+ cayley_dickson_construction,
31
+ cayley_dickson_algebra
19
32
  )
20
33
 
21
34
  # __all__ listesi, "from adnus import *" komutu kullanıldığında nelerin import edileceğini tanımlar.
@@ -29,5 +42,18 @@ __all__ = [
29
42
  "HyperrealNumber",
30
43
  "oresme_sequence",
31
44
  "harmonic_numbers",
32
- "binet_formula"
45
+ "binet_formula",
46
+ "generate_cayley_dickson_number",
47
+ "generate_cd_chain",
48
+ "reals",
49
+ "Complex",
50
+ "Quaternion",
51
+ "Octonion",
52
+ "Sedenion",
53
+ "Pathion",
54
+ "Chingon",
55
+ "Routon",
56
+ "Voudon",
57
+ "cayley_dickson_construction",
58
+ "cayley_dickson_algebra"
33
59
  ]
adnus/_version.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # _version.py
2
2
 
3
- __version__ = "0.1.1"
3
+ __version__ = "0.1.2"
4
4
  __license__ = "MIT"
5
5
  __description__ = "adnus (AdNuS): Advanced Number Systems."
6
6
  __author__ = "Mehmet Keçeci"
adnus/main.py CHANGED
@@ -8,7 +8,8 @@ from abc import ABC, abstractmethod
8
8
  from dataclasses import dataclass
9
9
  from fractions import Fraction
10
10
  import math
11
- from typing import List, Union, Generator, Tuple
11
+ from typing import List, Union, Generator, Tuple, Any
12
+ from hypercomplex import reals, Complex, Quaternion, Octonion, Sedenion, Pathion, Chingon, Routon, Voudon, cayley_dickson_construction, cayley_dickson_algebra
12
13
 
13
14
  class AdvancedNumber(ABC):
14
15
  """Abstract Base Class for advanced number systems."""
@@ -44,8 +45,18 @@ class BicomplexNumber(AdvancedNumber):
44
45
  Represents a bicomplex number z = z1 + z2j, where z1 and z2 are complex
45
46
  numbers and j^2 = -1, but j is an independent imaginary unit from i.
46
47
  """
47
- z1: complex
48
- z2: complex
48
+ z1: Complex
49
+ z2: Complex
50
+
51
+ def __init__(self, z1: Union[Complex, complex, float, int],
52
+ z2: Union[Complex, complex, float, int]):
53
+ # Convert inputs to Complex type if needed
54
+ if not isinstance(z1, Complex):
55
+ z1 = Complex(z1)
56
+ if not isinstance(z2, Complex):
57
+ z2 = Complex(z2)
58
+ object.__setattr__(self, 'z1', z1)
59
+ object.__setattr__(self, 'z2', z2)
49
60
 
50
61
  def __add__(self, other: BicomplexNumber) -> BicomplexNumber:
51
62
  if not isinstance(other, BicomplexNumber):
@@ -57,8 +68,8 @@ class BicomplexNumber(AdvancedNumber):
57
68
  return NotImplemented
58
69
  return BicomplexNumber(self.z1 - other.z1, self.z2 - other.z2)
59
70
 
60
- def __mul__(self, other: Union[BicomplexNumber, float, int, complex]) -> BicomplexNumber:
61
- if isinstance(other, (float, int, complex)):
71
+ def __mul__(self, other: Union[BicomplexNumber, float, int, complex, Complex]) -> BicomplexNumber:
72
+ if isinstance(other, (float, int, complex, Complex)):
62
73
  return BicomplexNumber(self.z1 * other, self.z2 * other)
63
74
  if not isinstance(other, BicomplexNumber):
64
75
  return NotImplemented
@@ -69,10 +80,26 @@ class BicomplexNumber(AdvancedNumber):
69
80
  )
70
81
 
71
82
  def __truediv__(self, other: BicomplexNumber) -> BicomplexNumber:
72
- # Division is more complex and requires the inverse.
73
- # For simplicity, this is left as an exercise. A common method involves
74
- # multiplying by the conjugate and dividing by the squared modulus.
75
- raise NotImplementedError("Division for bicomplex numbers is not implemented.")
83
+ # Division using the conjugate approach
84
+ if isinstance(other, (float, int, complex, Complex)):
85
+ return BicomplexNumber(self.z1 / other, self.z2 / other)
86
+
87
+ if not isinstance(other, BicomplexNumber):
88
+ return NotImplemented
89
+
90
+ # Compute the conjugate of the denominator
91
+ conjugate = BicomplexNumber(other.z1, -other.z2)
92
+
93
+ # Multiply numerator and denominator by conjugate
94
+ numerator = self * conjugate
95
+ denominator = other * conjugate
96
+
97
+ # Denominator should be a real number (only z1 component)
98
+ if abs(denominator.z2.real) > 1e-10 or abs(denominator.z2.imag) > 1e-10:
99
+ raise ValueError("Division resulted in non-real denominator")
100
+
101
+ return BicomplexNumber(numerator.z1 / denominator.z1.real,
102
+ numerator.z2 / denominator.z1.real)
76
103
 
77
104
  def __eq__(self, other) -> bool:
78
105
  if not isinstance(other, BicomplexNumber):
@@ -93,8 +120,8 @@ class NeutrosophicNumber(AdvancedNumber):
93
120
  Represents a neutrosophic number z = a + bI, where 'a' is the determinate part,
94
121
  'b' is the indeterminate part, and I is the indeterminacy, satisfying I^2 = I.
95
122
  """
96
- a: float
97
- b: float
123
+ a: Union[float, int, Fraction]
124
+ b: Union[float, int, Fraction]
98
125
 
99
126
  def __add__(self, other: NeutrosophicNumber) -> NeutrosophicNumber:
100
127
  if not isinstance(other, NeutrosophicNumber):
@@ -116,8 +143,23 @@ class NeutrosophicNumber(AdvancedNumber):
116
143
  )
117
144
 
118
145
  def __truediv__(self, other: NeutrosophicNumber) -> NeutrosophicNumber:
119
- # Division is not uniquely defined without further constraints.
120
- raise NotImplementedError("Division for neutrosophic numbers is not implemented.")
146
+ # Division using the conjugate approach
147
+ if not isinstance(other, NeutrosophicNumber):
148
+ return NotImplemented
149
+
150
+ # Compute conjugate (a - bI)
151
+ conjugate = NeutrosophicNumber(other.a, -other.b)
152
+
153
+ # Multiply numerator and denominator by conjugate
154
+ numerator = self * conjugate
155
+ denominator = other * conjugate
156
+
157
+ # Denominator should be a real number (only a component)
158
+ if abs(denominator.b) > 1e-10:
159
+ raise ValueError("Division resulted in non-real denominator")
160
+
161
+ return NeutrosophicNumber(numerator.a / denominator.a,
162
+ numerator.b / denominator.a)
121
163
 
122
164
  def __eq__(self, other) -> bool:
123
165
  if not isinstance(other, NeutrosophicNumber):
@@ -135,8 +177,18 @@ class NeutrosophicComplexNumber(AdvancedNumber):
135
177
  This can be seen as a neutrosophic number whose determinate and indeterminate
136
178
  parts are complex numbers.
137
179
  """
138
- determinate: complex
139
- indeterminate: complex
180
+ determinate: Complex
181
+ indeterminate: Complex
182
+
183
+ def __init__(self, determinate: Union[Complex, complex, float, int],
184
+ indeterminate: Union[Complex, complex, float, int]):
185
+ # Convert inputs to Complex type if needed
186
+ if not isinstance(determinate, Complex):
187
+ determinate = Complex(determinate)
188
+ if not isinstance(indeterminate, Complex):
189
+ indeterminate = Complex(indeterminate)
190
+ object.__setattr__(self, 'determinate', determinate)
191
+ object.__setattr__(self, 'indeterminate', indeterminate)
140
192
 
141
193
  def __add__(self, other: NeutrosophicComplexNumber) -> NeutrosophicComplexNumber:
142
194
  if not isinstance(other, NeutrosophicComplexNumber):
@@ -165,7 +217,23 @@ class NeutrosophicComplexNumber(AdvancedNumber):
165
217
  return NeutrosophicComplexNumber(determinate_part, indeterminate_part)
166
218
 
167
219
  def __truediv__(self, other: NeutrosophicComplexNumber) -> NeutrosophicComplexNumber:
168
- raise NotImplementedError("Division for neutrosophic complex numbers is not implemented.")
220
+ # Division using the conjugate approach
221
+ if not isinstance(other, NeutrosophicComplexNumber):
222
+ return NotImplemented
223
+
224
+ # Compute conjugate (C - DI)
225
+ conjugate = NeutrosophicComplexNumber(other.determinate, -other.indeterminate)
226
+
227
+ # Multiply numerator and denominator by conjugate
228
+ numerator = self * conjugate
229
+ denominator = other * conjugate
230
+
231
+ # Denominator should be a complex number (only determinate part)
232
+ if abs(denominator.indeterminate.real) > 1e-10 or abs(denominator.indeterminate.imag) > 1e-10:
233
+ raise ValueError("Division resulted in non-complex denominator")
234
+
235
+ return NeutrosophicComplexNumber(numerator.determinate / denominator.determinate,
236
+ numerator.indeterminate / denominator.determinate)
169
237
 
170
238
  def __eq__(self, other) -> bool:
171
239
  if not isinstance(other, NeutrosophicComplexNumber):
@@ -213,7 +281,24 @@ class NeutrosophicBicomplexNumber(AdvancedNumber):
213
281
  return NeutrosophicBicomplexNumber(determinate_part, indeterminate_part)
214
282
 
215
283
  def __truediv__(self, other: NeutrosophicBicomplexNumber) -> NeutrosophicBicomplexNumber:
216
- raise NotImplementedError("Division for neutrosophic bicomplex numbers is not implemented.")
284
+ # Division using the conjugate approach
285
+ if not isinstance(other, NeutrosophicBicomplexNumber):
286
+ return NotImplemented
287
+
288
+ # Compute conjugate (C - DI)
289
+ conjugate = NeutrosophicBicomplexNumber(other.determinate, -other.indeterminate)
290
+
291
+ # Multiply numerator and denominator by conjugate
292
+ numerator = self * conjugate
293
+ denominator = other * conjugate
294
+
295
+ # Denominator should be a bicomplex number (only determinate part)
296
+ if abs(denominator.indeterminate.z1.real) > 1e-10 or abs(denominator.indeterminate.z1.imag) > 1e-10 or \
297
+ abs(denominator.indeterminate.z2.real) > 1e-10 or abs(denominator.indeterminate.z2.imag) > 1e-10:
298
+ raise ValueError("Division resulted in non-bicomplex denominator")
299
+
300
+ return NeutrosophicBicomplexNumber(numerator.determinate / denominator.determinate,
301
+ numerator.indeterminate / denominator.determinate)
217
302
 
218
303
  def __eq__(self, other) -> bool:
219
304
  if not isinstance(other, NeutrosophicBicomplexNumber):
@@ -256,7 +341,7 @@ class HyperrealNumber(AdvancedNumber):
256
341
  # Avoid division by zero in the sequence
257
342
  def div_func(n):
258
343
  denominator = other.sequence_func(n)
259
- if denominator == 0:
344
+ if abs(denominator) < 1e-10:
260
345
  # This case needs a more rigorous definition based on the ultrafilter.
261
346
  # For simplicity, we return 0, but this is not generally correct.
262
347
  return 0
@@ -271,6 +356,63 @@ class HyperrealNumber(AdvancedNumber):
271
356
  def __repr__(self) -> str:
272
357
  return f"Hyperreal(sequence: {self.sequence_func(1)}, {self.sequence_func(2)}, ...)"
273
358
 
359
+ # =============================================
360
+ # Cayley-Dickson Construction Wrapper
361
+ # =============================================
362
+
363
+ def generate_cayley_dickson_number(dimension: int, *components: float) -> Any:
364
+ """
365
+ Creates a hypercomplex number using the Cayley-Dickson construction.
366
+
367
+ Args:
368
+ dimension: The dimension of the hypercomplex number (2^n)
369
+ *components: The components of the number
370
+
371
+ Returns:
372
+ A hypercomplex number of the specified dimension
373
+ """
374
+ if dimension not in [1, 2, 4, 8, 16, 32, 64, 128, 256]:
375
+ raise ValueError("Dimension must be a power of 2 up to 256")
376
+
377
+ if len(components) != dimension:
378
+ raise ValueError(f"Expected {dimension} components, got {len(components)}")
379
+
380
+ # Map dimension to the appropriate hypercomplex class
381
+ dimension_map = {
382
+ 1: reals,
383
+ 2: Complex,
384
+ 4: Quaternion,
385
+ 8: Octonion,
386
+ 16: Sedenion,
387
+ 32: Pathion,
388
+ 64: Chingon,
389
+ 128: Routon,
390
+ 256: Voudon
391
+ }
392
+
393
+ return dimension_map[dimension](*components)
394
+
395
+ # =============================================
396
+ # Cayley-Dickson Construction Helper
397
+ # =============================================
398
+
399
+ def generate_cd_chain(max_level: int = 8) -> List:
400
+ """
401
+ Creates a chain of Cayley-Dickson algebras up to the specified level.
402
+
403
+ Args:
404
+ max_level: Maximum level of the Cayley-Dickson construction
405
+
406
+ Returns:
407
+ List of hypercomplex number types [CD0, CD1, CD2, ..., CD_max_level]
408
+ """
409
+ CD = [reals()] # CD0 = Real numbers
410
+
411
+ for i in range(max_level):
412
+ CD.append(cayley_dickson_construction(CD[-1]))
413
+
414
+ return CD
415
+
274
416
 
275
417
  # =============================================
276
418
  # Helper Functions
@@ -303,3 +445,76 @@ def binet_formula(n: int) -> float:
303
445
  sqrt5 = math.sqrt(5)
304
446
  phi = (1 + sqrt5) / 2
305
447
  return (phi**n - (1 - phi)**n) / sqrt5
448
+
449
+ # =============================================
450
+ # Example Usage
451
+ # =============================================
452
+
453
+ if __name__ == "__main__":
454
+ # Create Cayley-Dickson chain
455
+ CD = generate_cd_chain(8) # Up to 256 dimensions (CD0 to CD8)
456
+
457
+ # CD chain mapping:
458
+ # CD[0] = Real numbers (1 dimension)
459
+ # CD[1] = Complex numbers (2 dimensions)
460
+ # CD[2] = Quaternions (4 dimensions)
461
+ # CD[3] = Octonions (8 dimensions)
462
+ # CD[4] = Sedenions (16 dimensions)
463
+ # CD[5] = Pathions (32 dimensions)
464
+ # CD[6] = Chingons (64 dimensions)
465
+ # CD[7] = Routons (128 dimensions)
466
+ # CD[8] = Voudons (256 dimensions)
467
+
468
+ # Create an octonion (8 dimensions)
469
+ octonion = CD[3](1, 0, 2, 0, 3) # Missing components auto-filled with zeros
470
+ print(f"Octonion: {octonion}") # -> (1 0 2 0 3 0 0 0)
471
+
472
+ # Create other types
473
+ complex_num = CD[1](1, 2) # Complex number
474
+ quaternion = CD[2](1, 2, 3, 4) # Quaternion
475
+ sedenion = CD[4](*range(1, 17)) # Sedenion with values 1-16
476
+
477
+ print(f"Complex: {complex_num}")
478
+ print(f"Quaternion: {quaternion}")
479
+ print(f"Sedenion: {sedenion}")
480
+
481
+ # Or use the predefined types directly
482
+ octonion2 = Octonion(1, 0, 2, 0, 3)
483
+ print(f"Octonion (predefined): {octonion2}")
484
+
485
+ # Bicomplex number example
486
+ bc1 = BicomplexNumber(Complex(1, 2), Complex(3, 4))
487
+ bc2 = BicomplexNumber(Complex(5, 6), Complex(7, 8))
488
+ print(f"Bicomplex multiplication: {bc1} * {bc2} = {bc1 * bc2}")
489
+
490
+
491
+ # Example usage of hypercomplex numbers
492
+ c1 = Complex(1, 2)
493
+ c2 = Complex(3, 4)
494
+ print(f"Complex numbers: {c1} + {c2} = {c1 + c2}")
495
+
496
+ q1 = Quaternion(1, 2, 3, 4)
497
+ q2 = Quaternion(5, 6, 7, 8)
498
+ print(f"Quaternions: {q1} * {q2} = {q1 * q2}")
499
+
500
+
501
+ # Create higher dimension numbers using cayley_dickson_algebra
502
+ octonion_type = cayley_dickson_algebra(3) # 2^3 = 8 dimensions
503
+ octonion = octonion_type(1, 2, 3, 4, 5, 6, 7, 8)
504
+ print(f"Octonion: {octonion}")
505
+
506
+ # Or use the predefined types
507
+ sedenion = Sedenion(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
508
+ print(f"Sedenion: {sedenion}") # 2^4 = 16 dimensions
509
+
510
+ pathion = Pathion(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32)
511
+ print(f"Pathion: {pathion}") # 2^5 = 32 dimensions
512
+
513
+ Real=reals()
514
+ print(Real(4)) # -> (4)
515
+ C = cayley_dickson_construction(Complex)
516
+ print(C(3-7j)) # -> (3 -7)
517
+ CD4 = cayley_dickson_construction(CD[1])
518
+ print(CD4(.1, -2.2, 3.3e3)) # -> (0.1 -2.2 3300 0)
519
+ CD[3] = cayley_dickson_construction(CD[2])
520
+ print(CD[3](1, 0, 2, 0, 3)) # -> (1 0 2 0 3 0 0 0)
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: adnus
3
- Version: 0.1.1
4
- Summary: A Python library for Advanced Number Systems (AdNuS), including Bicomplex, Neutrosophic, and Hyperreal numbers.
3
+ Version: 0.1.2
4
+ Summary: A Python library for Advanced Number Systems (AdNuS), including Bicomplex, Neutrosophic, Hyperreal numbers, reals, Complex, Quaternion, Octonion, Sedenion, Pathion, Chingon, Routon, Voudon.
5
5
  License: MIT
6
6
  Author: Mehmet Keçeci
7
7
  Author-email: mkececi@yaani.com
@@ -11,7 +11,8 @@ Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
14
- Requires-Dist: numpy (>=2.3.2,<3.0.0)
14
+ Requires-Dist: hypercomplex (==0.3.4)
15
+ Requires-Dist: numpy (>=2.3,<3.0)
15
16
  Description-Content-Type: text/markdown
16
17
 
17
18
  # adnus (AdNuS): Advanced Number Systems.
@@ -100,6 +101,15 @@ Description-Content-Type: text/markdown
100
101
  - **Hyperreal Numbers**: A conceptual implementation of hyperreal numbers.
101
102
  - **Extensible Design**: Built with an abstract base class to easily extend and add new number systems.
102
103
  - **Fully Typed**: The library is fully type-hinted for better code quality and maintainability.
104
+ - **Real numbers**
105
+ - **Complex numbers**
106
+ - **Quaternion numbers**
107
+ - **Octonion numbers**
108
+ - **Sedenion numbers**
109
+ - **Pathion numbers**
110
+ - **Chingon numbers**
111
+ - **Routon numbers**
112
+ - **Voudon numbers**
103
113
 
104
114
  ## Installation
105
115
 
@@ -146,6 +156,19 @@ print(f"Addition: {n1 + n2}")
146
156
  print(f"Multiplication: {n1 * n2}")
147
157
  ```
148
158
 
159
+ ```python
160
+ import adnus as ad
161
+ C = cayley_dickson_construction(ad.Complex)
162
+ print(C(3-7j))
163
+ ```
164
+
165
+ ```python
166
+ import adnus as ad
167
+ q1 = ad.Quaternion(1, 2, 3, 4)
168
+ q2 = ad.Quaternion(5, 6, 7, 8)
169
+ print(f"Quaternions: {q1} * {q2} = {q1 * q2}")
170
+ ```
171
+
149
172
  ## Running Tests
150
173
 
151
174
  To ensure everything is working correctly, you can run the included tests using `pytest`:
@@ -236,6 +259,8 @@ Keçeci, M. (2025). adnus [Data set]. WorkflowHub. https://doi.org/10.48546/work
236
259
 
237
260
  Keçeci, M. (2025). adnus. Open Science Articles (OSAs), Zenodo. https://doi.org/10.5281/zenodo.16341919
238
261
 
262
+ ```
263
+
239
264
  ### Chicago
240
265
 
241
266
  ```
@@ -0,0 +1,7 @@
1
+ adnus/__init__.py,sha256=kTimUAw-wKQMWgyjXx5u7aA6uQ6itzSO_0UfjKY6Yoc,1439
2
+ adnus/_version.py,sha256=OZVSyDN1PQ7mCrsn9lH_hK_n4AsLIoshK55HG5_i_qw,370
3
+ adnus/main.py,sha256=i4Sq0dEWNcjLoGIU46OdAbnlWV27aM0gGMG-PlpCDBk,20216
4
+ adnus-0.1.2.dist-info/LICENSE,sha256=NJZsJEbQuKzxn1mWPWCbRx8jRUqGS22thl8wwuRQJ9c,1071
5
+ adnus-0.1.2.dist-info/METADATA,sha256=UyuHsOcHnMIyycNSJZwAFgltspzTMOcc5jXiZeXMSY8,9600
6
+ adnus-0.1.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
7
+ adnus-0.1.2.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- adnus/__init__.py,sha256=H5pQpNmEf921qquSDg5B2Mo7Sxt8ZkxyDk9iWNymOV4,917
2
- adnus/_version.py,sha256=guuWvmmZ0FRRBsgXWGYvookl-2X3wjLCCuYAU_BChMk,370
3
- adnus/main.py,sha256=uyo7DeDXDkzUvC_P8ZXbkTeFqN8Pt7cqjPsQ6pWLcnQ,11825
4
- adnus-0.1.1.dist-info/LICENSE,sha256=NJZsJEbQuKzxn1mWPWCbRx8jRUqGS22thl8wwuRQJ9c,1071
5
- adnus-0.1.1.dist-info/METADATA,sha256=8nbpaVhyhnDmx18k-mbuqHFpIibjTYI_brNmjKLzjLw,9046
6
- adnus-0.1.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
7
- adnus-0.1.1.dist-info/RECORD,,
File without changes
File without changes