Skip to content

Commit 3376e6d

Browse files
committed
Remove inverse calculations on import by pre-computing values
There were a few cases where we were performing inverse matrix calculations on import of files. These are now pre-computed for efficiency.
1 parent 14564f3 commit 3376e6d

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

coloraide/algebra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5272,7 +5272,7 @@ def fnnls(
52725272
A fast non-negativity-constrained least squares
52735273
https://www.researchgate.net/publication/230554373_A_Fast_Non-negativity-constrained_Least_Squares_Algorithm
52745274
Rasmus Bro and Sijmen De Jong
5275-
Journal of Chemometrics. 11, 393401 (1997)
5275+
Journal of Chemometrics. 11, 393-401 (1997)
52765276
"""
52775277

52785278
m, n = _quick_shape(A)

coloraide/spaces/sucs.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@
1414

1515
# Iab transformation matrices
1616
TO_IAB = [
17-
alg.divide([200.0, 100.0, 5.0], 3.05, dims=alg.D1_SC),
17+
# `alg.divide([200.0, 100.0, 5.0], 3.05, dims=alg.D1_SC),`
18+
[65.57377049180329, 32.786885245901644, 1.639344262295082],
1819
[430.0, -470.0, 40.0],
1920
[49.0, 49.0, -98.0]
2021
]
21-
FROM_IAB = alg.inv(TO_IAB)
22+
FROM_IAB = [
23+
[0.01, 0.0007468123861566483, 0.0004721014088695587],
24+
[0.009999999999999998, -0.0014754098360655738, -0.00043492806958849117],
25+
[0.009999999999999997, -0.0003642987249544624, -0.010185494963012527]
26+
]
2227

2328

2429
def sucs_to_xyz(ich: Vector) -> Vector:

coloraide/spaces/zcam.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636
[3.524, -4.066708, 0.542708],
3737
[0.199076, 1.096799, -1.295875]
3838
]
39-
IZAZBZ_TO_LMS_P = alg.inv(LMS_P_TO_IZAZBZ)
39+
IZAZBZ_TO_LMS_P = [
40+
[1.0, 0.2772100865430786, 0.11609463231223774],
41+
[1.0, 0.0, 0.0],
42+
[1.0, 0.042585801245220344, -0.75384457989992]
43+
]
4044

4145
SURROUND = {
4246
'dark': (0.8, 0.525, 0.8),

0 commit comments

Comments
 (0)