tensorpow 0.1.0__tar.gz
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.
- tensorpow-0.1.0/LICENSE +318 -0
- tensorpow-0.1.0/MANIFEST.in +10 -0
- tensorpow-0.1.0/PKG-INFO +118 -0
- tensorpow-0.1.0/README.md +92 -0
- tensorpow-0.1.0/pyproject.toml +46 -0
- tensorpow-0.1.0/setup.cfg +4 -0
- tensorpow-0.1.0/tensorpow/__init__.py +17 -0
- tensorpow-0.1.0/tensorpow/core.py +480 -0
- tensorpow-0.1.0/tensorpow/file_handler.py +62 -0
- tensorpow-0.1.0/tensorpow/sl2_loader.py +70 -0
- tensorpow-0.1.0/tensorpow.egg-info/PKG-INFO +118 -0
- tensorpow-0.1.0/tensorpow.egg-info/SOURCES.txt +14 -0
- tensorpow-0.1.0/tensorpow.egg-info/dependency_links.txt +1 -0
- tensorpow-0.1.0/tensorpow.egg-info/requires.txt +7 -0
- tensorpow-0.1.0/tensorpow.egg-info/top_level.txt +1 -0
- tensorpow-0.1.0/tests/test_core.py +176 -0
tensorpow-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
Preamble
|
|
9
|
+
|
|
10
|
+
The GNU General Public License is a free, copyleft license for
|
|
11
|
+
software and other kinds of works.
|
|
12
|
+
|
|
13
|
+
The licenses for most software and other practical works are designed
|
|
14
|
+
to take away your freedom to share and change the works. By contrast,
|
|
15
|
+
the GNU General Public License is intended to guarantee your freedom to
|
|
16
|
+
share and change all versions of a program--to make sure it remains free
|
|
17
|
+
software for all its users. We, the Free Software Foundation, use the
|
|
18
|
+
GNU General Public License for most of our software; it applies also to
|
|
19
|
+
any other work released this way by its authors. You can apply it to
|
|
20
|
+
your programs, too.
|
|
21
|
+
|
|
22
|
+
When we speak of free software, we are referring to freedom, not
|
|
23
|
+
price. Our General Public Licenses are designed to make sure that you
|
|
24
|
+
have the freedom to distribute copies of free software (and charge for
|
|
25
|
+
them if you wish), that you receive source code or can get it if you
|
|
26
|
+
want it, that you can change the software or use pieces of it in new
|
|
27
|
+
free programs, and that you know you can do these things.
|
|
28
|
+
|
|
29
|
+
To protect your rights, we need to prevent others from denying you
|
|
30
|
+
these rights or asking you to surrender the rights. Therefore, you have
|
|
31
|
+
certain responsibilities if you distribute copies of the software, or if
|
|
32
|
+
you modify it: responsibilities to respect the freedom of others.
|
|
33
|
+
|
|
34
|
+
For example, if you distribute copies of such a program, whether
|
|
35
|
+
gratis or for a fee, you must pass on to the recipients the same
|
|
36
|
+
freedoms that you received. You must make sure that they, too, receive
|
|
37
|
+
or can get the source code. And you must show them these terms so they
|
|
38
|
+
know their rights.
|
|
39
|
+
|
|
40
|
+
Developers that use the GNU GPL protect your rights with two steps:
|
|
41
|
+
(1) assert copyright on the software, and (2) offer you this License
|
|
42
|
+
giving you legal permission to copy, distribute and/or modify it.
|
|
43
|
+
|
|
44
|
+
For the developers' and authors' protection, the GPL clearly explains
|
|
45
|
+
that there is no warranty for this free software. For both users' and
|
|
46
|
+
authors' sake, the GPL requires that modified versions be marked as
|
|
47
|
+
changed, so that their problems will not be attributed erroneously to
|
|
48
|
+
authors of previous versions.
|
|
49
|
+
|
|
50
|
+
Some devices are designed to deny users access to install or run
|
|
51
|
+
modified versions of the software inside them, although the manufacturer
|
|
52
|
+
can do so. This is fundamentally incompatible with the aim of
|
|
53
|
+
protecting users' freedom to change the software. The systematic
|
|
54
|
+
pattern of such abuse occurs in the area of products for individuals to
|
|
55
|
+
use, which is precisely where it is most unacceptable. Therefore, we
|
|
56
|
+
have designed this version of the GPL to prohibit the practice for those
|
|
57
|
+
products. If such problems arise substantially in other domains, we
|
|
58
|
+
stand ready to extend this provision to those domains in future versions
|
|
59
|
+
of the GPL, as needed to protect the freedom of users.
|
|
60
|
+
|
|
61
|
+
Finally, every program is threatened constantly by software patents.
|
|
62
|
+
States should not allow patents to restrict development and use of
|
|
63
|
+
software on general-purpose computers, but in those that do, we wish to
|
|
64
|
+
avoid the special danger that patents applied to a free program could
|
|
65
|
+
make it effectively proprietary. To prevent this, the GPL assures that
|
|
66
|
+
patents cannot be used to render the program non-free.
|
|
67
|
+
|
|
68
|
+
The precise terms and conditions for copying, distribution and
|
|
69
|
+
modification follow.
|
|
70
|
+
|
|
71
|
+
TERMS AND CONDITIONS
|
|
72
|
+
|
|
73
|
+
0. Definitions.
|
|
74
|
+
|
|
75
|
+
"This License" refers to version 3 of the GNU General Public License.
|
|
76
|
+
|
|
77
|
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
78
|
+
works, such as semiconductor masks.
|
|
79
|
+
|
|
80
|
+
"The Program" refers to any copyrightable work licensed under this
|
|
81
|
+
License. Each licensee is addressed as "you". "Licensees" and
|
|
82
|
+
"recipients" may be individuals or organizations.
|
|
83
|
+
|
|
84
|
+
To "modify" a work means to copy from or adapt all or part of the work
|
|
85
|
+
in a fashion requiring copyright permission, other than the making of an
|
|
86
|
+
exact copy. The resulting work is called a "modified version" of the
|
|
87
|
+
earlier work or a work "based on" the earlier work.
|
|
88
|
+
|
|
89
|
+
A "covered work" means either the unmodified Program or a work based
|
|
90
|
+
on the Program.
|
|
91
|
+
|
|
92
|
+
To "propagate" a work means to do anything with it that, without
|
|
93
|
+
permission, would make you directly or secondarily liable for
|
|
94
|
+
infringement under applicable copyright law, except executing it on a
|
|
95
|
+
computer or modifying a private copy. Propagation includes copying,
|
|
96
|
+
distribution (with or without modification), making available to the
|
|
97
|
+
public, and in some countries other activities as well.
|
|
98
|
+
|
|
99
|
+
To "convey" a work means any kind of propagation that enables other
|
|
100
|
+
parties to make or receive copies. Mere interaction with a user through
|
|
101
|
+
a computer network, with no transfer of a copy, is not conveying.
|
|
102
|
+
|
|
103
|
+
An interactive user interface displays "Appropriate Legal Notices"
|
|
104
|
+
to the extent that it includes a convenient and prominently visible
|
|
105
|
+
feature that (1) displays an appropriate copyright notice, and (2)
|
|
106
|
+
tells the user that there is no warranty for the work (except to the
|
|
107
|
+
extent that warranties are provided), that licensees may convey the
|
|
108
|
+
work under this License, and how to view a copy of this License. If
|
|
109
|
+
the interface presents a list of user commands or options, such as a
|
|
110
|
+
menu, a prominent item in the list meets this definition.
|
|
111
|
+
|
|
112
|
+
1. Source Code.
|
|
113
|
+
|
|
114
|
+
The source code for a work means the preferred form of the work for
|
|
115
|
+
making modifications to it. "Object code" means any non-source form of
|
|
116
|
+
a work.
|
|
117
|
+
|
|
118
|
+
A "Standard Interface" means an interface that either is an official
|
|
119
|
+
standard defined by a recognized standards body, or, in the case of
|
|
120
|
+
a
|
|
121
|
+
widely used interface, one that is well-documented and public.
|
|
122
|
+
|
|
123
|
+
2. Basic Permissions.
|
|
124
|
+
|
|
125
|
+
All rights granted under this License are granted for the term of
|
|
126
|
+
copyright on the Program, and are irrevocable provided the stated
|
|
127
|
+
conditions are met. This License explicitly affirms your right to
|
|
128
|
+
|
|
129
|
+
make, run and propagate covered works in the ways permitted by this
|
|
130
|
+
License.
|
|
131
|
+
|
|
132
|
+
The above rights are perpetual, worldwide, non-exclusive, no-charge,
|
|
133
|
+
royalty-free and sublicensable provided that you comply with this
|
|
134
|
+
License.
|
|
135
|
+
|
|
136
|
+
You may convey a covered work under this License only if you also
|
|
137
|
+
meet all of these conditions. If you do not, then you have no
|
|
138
|
+
permission to propagate or modify the work. However, parties who have
|
|
139
|
+
received copies, or rights, from you under this License will not have
|
|
140
|
+
their
|
|
141
|
+
rights revoked so long as such parties remain in full compliance.
|
|
142
|
+
|
|
143
|
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
144
|
+
|
|
145
|
+
No covered work shall be deemed part of an effective technological
|
|
146
|
+
protection measure under applicable law fulfilling obligations under
|
|
147
|
+
article 11 of the WIPO copyright treaty.
|
|
148
|
+
|
|
149
|
+
4. Conveying Verbatim Copies.
|
|
150
|
+
|
|
151
|
+
You may convey verbatim copies of the Program's source code as you
|
|
152
|
+
receive it, in any medium, provided that you conspicuously and
|
|
153
|
+
appropriately publish on each copy an appropriate copyright notice;
|
|
154
|
+
keep intact all notices stating that this License and any
|
|
155
|
+
non-permissive terms added in accord with section 7 apply to the code;
|
|
156
|
+
keep intact all notices of the absence of any warranty; and give all
|
|
157
|
+
recipients a copy of this License along with the Program.
|
|
158
|
+
|
|
159
|
+
5. Conveying Modified Source Versions.
|
|
160
|
+
|
|
161
|
+
You may convey a work based on the Program, or the modifications to
|
|
162
|
+
produce it from the Program, in the form of source code under the
|
|
163
|
+
terms of section 4, provided that you also meet all of these
|
|
164
|
+
conditions:
|
|
165
|
+
|
|
166
|
+
a) The work must carry prominent notices stating that you modified
|
|
167
|
+
it, and giving a relevant date.
|
|
168
|
+
|
|
169
|
+
b) The work must carry prominent notices stating that it is
|
|
170
|
+
released under this License and any conditions added under section
|
|
171
|
+
7. This requirement modifies the requirement in section 4 to keep
|
|
172
|
+
intact all notices.
|
|
173
|
+
|
|
174
|
+
c) You must license the entire work, as a whole, under this
|
|
175
|
+
License to anyone who comes into possession of a copy. This
|
|
176
|
+
License will therefore apply, along with any applicable section 7
|
|
177
|
+
additional terms, to the whole of the work, and all its parts, who
|
|
178
|
+
are not otherwise permitted to copy or distribute under this
|
|
179
|
+
License.
|
|
180
|
+
|
|
181
|
+
d) If the work has interactive user interfaces, each must display
|
|
182
|
+
Appropriate Legal Notices; however, if the Program has interactive
|
|
183
|
+
interfaces that do not display Appropriate Legal Notices, your
|
|
184
|
+
work need not make them do so.
|
|
185
|
+
|
|
186
|
+
6. Conveying Non-Source Forms.
|
|
187
|
+
|
|
188
|
+
You may convey a covered work in object code form under the terms
|
|
189
|
+
of sections 4 and 5, provided that you also convey the machine-readable
|
|
190
|
+
Corresponding Source under the terms of this License, and provided that
|
|
191
|
+
you meet the requirements of one of the following:
|
|
192
|
+
|
|
193
|
+
a) Convey the object code with the Corresponding Source in a
|
|
194
|
+
physical product.
|
|
195
|
+
|
|
196
|
+
b) Convey the object code with a written offer, valid for at
|
|
197
|
+
least three years, to give anyone who possesses the object code a
|
|
198
|
+
copy of the Corresponding Source on a durable physical medium if
|
|
199
|
+
you received the object code with such an offer.
|
|
200
|
+
|
|
201
|
+
c) Convey individual copies of the object code with a copy of the
|
|
202
|
+
written offer to provide the Corresponding Source. This is
|
|
203
|
+
allowed only occasionally and noncommercially, and only if you
|
|
204
|
+
received the object code with such a copy of the written offer.
|
|
205
|
+
|
|
206
|
+
A "User Product" means any tangible personal property which contains
|
|
207
|
+
software, or a component of software, that is conveyed to the user
|
|
208
|
+
|
|
209
|
+
under a transaction involving the transfer of possession. It does not
|
|
210
|
+
include a server running the software for the user's own use.
|
|
211
|
+
|
|
212
|
+
The Corresponding Source conveyed in accordance with this section must
|
|
213
|
+
be the complete source code for the work described in section 6 and
|
|
214
|
+
|
|
215
|
+
must be conveyed in one of the following ways: a) accompany the object
|
|
216
|
+
code, or b) be provided by written offer, or c) be made available
|
|
217
|
+
from a designated place.
|
|
218
|
+
|
|
219
|
+
7. Additional Terms.
|
|
220
|
+
|
|
221
|
+
"Additional permissions" are terms that supplement the terms of this
|
|
222
|
+
License by making exceptions from one or more of its conditions.
|
|
223
|
+
|
|
224
|
+
Additional permissions that are applicable to the entire Program shall
|
|
225
|
+
be treated as though they were included in this License, to the extent
|
|
226
|
+
that they are valid under applicable law.
|
|
227
|
+
|
|
228
|
+
If other material is included with the Program, such as source code
|
|
229
|
+
from a different program, their licensing terms may be separate from
|
|
230
|
+
this License.
|
|
231
|
+
|
|
232
|
+
8. Termination.
|
|
233
|
+
|
|
234
|
+
You may not propagate or modify a covered work except as expressly
|
|
235
|
+
provided under this License. Any attempt otherwise to propagate or
|
|
236
|
+
|
|
237
|
+
modify it is void, and will terminate your rights under this License
|
|
238
|
+
|
|
239
|
+
unless the licensee has expressly received permission from you to do
|
|
240
|
+
otherwise or is solely responsible for possessing or providing the
|
|
241
|
+
covered work.
|
|
242
|
+
|
|
243
|
+
9. Acceptance Not Required for Having Copies.
|
|
244
|
+
|
|
245
|
+
You are not required to accept this License in order to receive or
|
|
246
|
+
run a copy of the Program. Ancillary propagation of a covered work
|
|
247
|
+
is permitted by the conditions of this License.
|
|
248
|
+
|
|
249
|
+
10. Automatic Licensing of Downstream Recipients.
|
|
250
|
+
|
|
251
|
+
Each time you convey a covered work, the recipient automatically
|
|
252
|
+
receives a license from the original licensors, to run, modify and
|
|
253
|
+
|
|
254
|
+
propagate that work, subject to this License.
|
|
255
|
+
|
|
256
|
+
11. Patents.
|
|
257
|
+
|
|
258
|
+
A patent license is a license to make, use, sell, offer for sale, import
|
|
259
|
+
and otherwise run, modify and propagate a covered work, in a manner
|
|
260
|
+
consistent with the above definition of patent license.
|
|
261
|
+
|
|
262
|
+
12. No Surrender of Others' Freedom.
|
|
263
|
+
|
|
264
|
+
If conditions are imposed on you (whether by court order, agreement or
|
|
265
|
+
otherwise) that contradict the conditions of this License, they do not
|
|
266
|
+
excuse you from the conditions of this License.
|
|
267
|
+
|
|
268
|
+
13. Use with the GNU Affero General Public License.
|
|
269
|
+
|
|
270
|
+
Notwithstanding any other provision of this License, you have
|
|
271
|
+
permission to link or combine any covered work with a work licensed
|
|
272
|
+
under version 3 of the GNU Affero General Public License into a
|
|
273
|
+
single combined work, and to convey the resulting work.
|
|
274
|
+
|
|
275
|
+
14. Revised Versions of this License.
|
|
276
|
+
|
|
277
|
+
The Free Software Foundation may publish revised and/or new versions of
|
|
278
|
+
the GNU General Public License from time to time. Such new versions
|
|
279
|
+
will be similar in spirit to the present version, but may differ in
|
|
280
|
+
|
|
281
|
+
detail to address new problems or concerns.
|
|
282
|
+
|
|
283
|
+
Each version is given a distinguishing version number. If the
|
|
284
|
+
Program specifies that a certain numbered version of the GNU General
|
|
285
|
+
Public License "or any later version" applies to it, you have the
|
|
286
|
+
|
|
287
|
+
option of following the terms and conditions either of that version or
|
|
288
|
+
of any later version published by the Free Software Foundation.
|
|
289
|
+
|
|
290
|
+
If the Program does not specify a version number of the GNU General
|
|
291
|
+
Public License, you may choose any version ever published by the Free
|
|
292
|
+
Software Foundation.
|
|
293
|
+
|
|
294
|
+
END OF TERMS AND CONDITIONS
|
|
295
|
+
|
|
296
|
+
How to Apply These Terms to Your New Programs
|
|
297
|
+
|
|
298
|
+
If you develop a new program, and you want it to be of the greatest
|
|
299
|
+
possible use to the public, the best way to achieve this is to make it
|
|
300
|
+
free software which everyone can redistribute and change.
|
|
301
|
+
|
|
302
|
+
To do so, attach the following notices to the program. It is safest
|
|
303
|
+
to use the exact notices as given below:
|
|
304
|
+
|
|
305
|
+
<one line to give the program's name and a brief idea of what it does.
|
|
306
|
+
Copyright (C) 2026 <your name here>
|
|
307
|
+
This program is free software: you can redistribute it and/or modify
|
|
308
|
+
it under the terms of the GNU General Public License as published by
|
|
309
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
310
|
+
(at your option) any later version.
|
|
311
|
+
|
|
312
|
+
This program is distributed in the hope that it will be useful,
|
|
313
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
314
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
315
|
+
GNU General Public License for more details.
|
|
316
|
+
|
|
317
|
+
You should have received a copy of the GNU General Public License
|
|
318
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
tensorpow-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tensorpow
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Norms and block decompositions for 2x2 and 3x3 tensor powers.
|
|
5
|
+
Author-email: Martin Juhász <martin.juhasz11@gmail.com>
|
|
6
|
+
License: GPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/juhaszmartin/tensorpow
|
|
8
|
+
Project-URL: Repository, https://github.com/juhaszmartin/tensorpow
|
|
9
|
+
Project-URL: Issues, https://github.com/juhaszmartin/tensorpow/issues
|
|
10
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
16
|
+
Requires-Python: <4,>=3.11
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: numpy
|
|
20
|
+
Requires-Dist: pulp
|
|
21
|
+
Requires-Dist: scipy
|
|
22
|
+
Requires-Dist: sympy
|
|
23
|
+
Provides-Extra: test
|
|
24
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# tensorpow
|
|
28
|
+
|
|
29
|
+
`tensorpow` is a small Python library for working with norms and
|
|
30
|
+
representations of tensor powers. Base matrices can be either **2×2**
|
|
31
|
+
(using SL(2) representation data) or **3×3** (using SU(3) representation
|
|
32
|
+
data). The **tensor power** itself may be any positive integer – the
|
|
33
|
+
library uses precomputed representation data indexed by that power. A
|
|
34
|
+
class-based interface computes block decompositions via precomputed SL(2)/SU(3)
|
|
35
|
+
data and evaluates quantities such as Schatten‑p norms without building the
|
|
36
|
+
full Kronecker power.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
Requires **Python 3.11–3.13**.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install tensorpow
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For development:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install -e ".[test]"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Dependencies (`numpy`, `pulp`, `scipy`, `sympy`) are installed automatically.
|
|
53
|
+
|
|
54
|
+
### Data limits
|
|
55
|
+
|
|
56
|
+
Precomputed SU(3) symmetric representation data is bundled for degrees **1 through 26**. Some large 3×3 tensor powers may require higher degrees; those cases raise a clear error.
|
|
57
|
+
|
|
58
|
+
Precomputed SL(2) data (``sl2reps.txt``) supports 2×2 tensor powers **n ≤ 79**.
|
|
59
|
+
|
|
60
|
+
## Quick start
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from tensorpow import TensorPowerCalculator
|
|
64
|
+
import numpy as np
|
|
65
|
+
|
|
66
|
+
# Example 1: 3×3 matrices (SU(3) case)
|
|
67
|
+
A = np.eye(3)
|
|
68
|
+
B = 2 * np.eye(3)
|
|
69
|
+
calc = TensorPowerCalculator() # no args
|
|
70
|
+
# compute Schatten‑2 norm of A⊗A - 1/2 * B⊗B (tensorpower=2)
|
|
71
|
+
norm_3x3 = calc.schatten_p_norm_weighted([A, B], n=2, p=2, coeffs=[1.0, -0.5])
|
|
72
|
+
print(f"3×3 result: {norm_3x3}")
|
|
73
|
+
|
|
74
|
+
# Example 2: 2×2 matrices (SL(2) case)
|
|
75
|
+
C = np.eye(2)
|
|
76
|
+
D = 2 * np.eye(2)
|
|
77
|
+
# compute Schatten‑2 norm of C⊗C - 1/2 * D⊗D (tensorpower=2)
|
|
78
|
+
norm_2x2 = calc.schatten_p_norm_weighted([C, D], n=2, p=2, coeffs=[1.0, -0.5])
|
|
79
|
+
print(f"2×2 result: {norm_2x2}")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Only the `schatten_p_norm_weighted` method is currently implemented. Both 2×2 and
|
|
83
|
+
3×3 matrices are fully supported; the library automatically dispatches to the
|
|
84
|
+
appropriate representation system (SL(2) or SU(3)) based on matrix dimension.
|
|
85
|
+
|
|
86
|
+
### Precomputed data
|
|
87
|
+
|
|
88
|
+
- **2×2 (SL(2)):** requires `data/sl2reps.txt` (bundled in the public
|
|
89
|
+
`tensorpow` package). Supports tensor power **n ≤ 79** (representations
|
|
90
|
+
Sym^k for k = 0..79). Regenerate with:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
python -m tensorprod.sl2_sym_runner --max-k 79
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
- **3×3 (SU(3)):** requires `data/piM_sym_<deg>_*.npz` files for the degrees
|
|
97
|
+
used by the Pieri decomposition at your chosen `n`.
|
|
98
|
+
Additional routines (e.g. other norms or eigenvalue statistics) can be added to
|
|
99
|
+
`TensorPowerCalculator` and will automatically reuse the underlying block
|
|
100
|
+
decomposition.
|
|
101
|
+
|
|
102
|
+
## Package structure
|
|
103
|
+
|
|
104
|
+
- `tensorpow/core.py` – main implementation and `TensorPowerCalculator`,
|
|
105
|
+
includes both SL(2) (2×2) and SU(3) (3×3) block decomposition logic
|
|
106
|
+
- `tensorpow/file_handler.py` – loaders for bundled `_data/` NPZ tensors
|
|
107
|
+
compressed SU(3) representation data
|
|
108
|
+
data (not part of the runtime API)
|
|
109
|
+
- `tensorpow/sl2_loader.py` – loads `data/sl2reps.txt` at runtime
|
|
110
|
+
- `tensorpow/sl2_sym_runner.py` – generator for `data/sl2reps.txt` (dev only)
|
|
111
|
+
|
|
112
|
+
## Testing
|
|
113
|
+
|
|
114
|
+
Run `pytest tests` to exercise the small test suite.
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
GNU GPLv3 or later (see `LICENSE`).
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# tensorpow
|
|
2
|
+
|
|
3
|
+
`tensorpow` is a small Python library for working with norms and
|
|
4
|
+
representations of tensor powers. Base matrices can be either **2×2**
|
|
5
|
+
(using SL(2) representation data) or **3×3** (using SU(3) representation
|
|
6
|
+
data). The **tensor power** itself may be any positive integer – the
|
|
7
|
+
library uses precomputed representation data indexed by that power. A
|
|
8
|
+
class-based interface computes block decompositions via precomputed SL(2)/SU(3)
|
|
9
|
+
data and evaluates quantities such as Schatten‑p norms without building the
|
|
10
|
+
full Kronecker power.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Requires **Python 3.11–3.13**.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install tensorpow
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For development:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install -e ".[test]"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Dependencies (`numpy`, `pulp`, `scipy`, `sympy`) are installed automatically.
|
|
27
|
+
|
|
28
|
+
### Data limits
|
|
29
|
+
|
|
30
|
+
Precomputed SU(3) symmetric representation data is bundled for degrees **1 through 26**. Some large 3×3 tensor powers may require higher degrees; those cases raise a clear error.
|
|
31
|
+
|
|
32
|
+
Precomputed SL(2) data (``sl2reps.txt``) supports 2×2 tensor powers **n ≤ 79**.
|
|
33
|
+
|
|
34
|
+
## Quick start
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from tensorpow import TensorPowerCalculator
|
|
38
|
+
import numpy as np
|
|
39
|
+
|
|
40
|
+
# Example 1: 3×3 matrices (SU(3) case)
|
|
41
|
+
A = np.eye(3)
|
|
42
|
+
B = 2 * np.eye(3)
|
|
43
|
+
calc = TensorPowerCalculator() # no args
|
|
44
|
+
# compute Schatten‑2 norm of A⊗A - 1/2 * B⊗B (tensorpower=2)
|
|
45
|
+
norm_3x3 = calc.schatten_p_norm_weighted([A, B], n=2, p=2, coeffs=[1.0, -0.5])
|
|
46
|
+
print(f"3×3 result: {norm_3x3}")
|
|
47
|
+
|
|
48
|
+
# Example 2: 2×2 matrices (SL(2) case)
|
|
49
|
+
C = np.eye(2)
|
|
50
|
+
D = 2 * np.eye(2)
|
|
51
|
+
# compute Schatten‑2 norm of C⊗C - 1/2 * D⊗D (tensorpower=2)
|
|
52
|
+
norm_2x2 = calc.schatten_p_norm_weighted([C, D], n=2, p=2, coeffs=[1.0, -0.5])
|
|
53
|
+
print(f"2×2 result: {norm_2x2}")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Only the `schatten_p_norm_weighted` method is currently implemented. Both 2×2 and
|
|
57
|
+
3×3 matrices are fully supported; the library automatically dispatches to the
|
|
58
|
+
appropriate representation system (SL(2) or SU(3)) based on matrix dimension.
|
|
59
|
+
|
|
60
|
+
### Precomputed data
|
|
61
|
+
|
|
62
|
+
- **2×2 (SL(2)):** requires `data/sl2reps.txt` (bundled in the public
|
|
63
|
+
`tensorpow` package). Supports tensor power **n ≤ 79** (representations
|
|
64
|
+
Sym^k for k = 0..79). Regenerate with:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
python -m tensorprod.sl2_sym_runner --max-k 79
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- **3×3 (SU(3)):** requires `data/piM_sym_<deg>_*.npz` files for the degrees
|
|
71
|
+
used by the Pieri decomposition at your chosen `n`.
|
|
72
|
+
Additional routines (e.g. other norms or eigenvalue statistics) can be added to
|
|
73
|
+
`TensorPowerCalculator` and will automatically reuse the underlying block
|
|
74
|
+
decomposition.
|
|
75
|
+
|
|
76
|
+
## Package structure
|
|
77
|
+
|
|
78
|
+
- `tensorpow/core.py` – main implementation and `TensorPowerCalculator`,
|
|
79
|
+
includes both SL(2) (2×2) and SU(3) (3×3) block decomposition logic
|
|
80
|
+
- `tensorpow/file_handler.py` – loaders for bundled `_data/` NPZ tensors
|
|
81
|
+
compressed SU(3) representation data
|
|
82
|
+
data (not part of the runtime API)
|
|
83
|
+
- `tensorpow/sl2_loader.py` – loads `data/sl2reps.txt` at runtime
|
|
84
|
+
- `tensorpow/sl2_sym_runner.py` – generator for `data/sl2reps.txt` (dev only)
|
|
85
|
+
|
|
86
|
+
## Testing
|
|
87
|
+
|
|
88
|
+
Run `pytest tests` to exercise the small test suite.
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
GNU GPLv3 or later (see `LICENSE`).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tensorpow"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Norms and block decompositions for 2x2 and 3x3 tensor powers."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11,<4"
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Martin Juhász", email = "martin.juhasz11@gmail.com"},
|
|
13
|
+
]
|
|
14
|
+
license = {text = "GPL-3.0-or-later"}
|
|
15
|
+
classifiers = [
|
|
16
|
+
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"numpy",
|
|
25
|
+
"pulp",
|
|
26
|
+
"scipy",
|
|
27
|
+
"sympy",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
test = ["pytest>=8"]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/juhaszmartin/tensorpow"
|
|
35
|
+
Repository = "https://github.com/juhaszmartin/tensorpow"
|
|
36
|
+
Issues = "https://github.com/juhaszmartin/tensorpow/issues"
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.packages.find]
|
|
39
|
+
where = ["."]
|
|
40
|
+
include = ["tensorpow*"]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.package-data]
|
|
43
|
+
tensorpow = ["_data/*.npz", "_data/sl2reps.txt"]
|
|
44
|
+
|
|
45
|
+
[tool.pytest.ini_options]
|
|
46
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Top-level package for the ``tensorpow`` library."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
6
|
+
|
|
7
|
+
from .core import TensorPowerCalculator, solve_su3_pieri
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"TensorPowerCalculator",
|
|
11
|
+
"solve_su3_pieri",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
__version__ = version("tensorpow")
|
|
16
|
+
except PackageNotFoundError:
|
|
17
|
+
__version__ = "0.1.0"
|