@@ -193,7 +193,7 @@ Min tropical linear space
193
193
```
194
194
"""
195
195
function tropical_linear_space (k:: Int , n:: Int , plueckerVector:: Vector , nu:: TropicalSemiringMap = tropical_semiring_map (parent (first (plueckerVector))); weighted_polyhedral_complex_only:: Bool = false )
196
- TropL = tropical_linear_space (AbstractAlgebra. combinations (1 : n,k), nu .(plueckerVector), weighted_polyhedral_complex_only= weighted_polyhedral_complex_only)
196
+ TropL = tropical_linear_space (AbstractAlgebra. combinations (n,k), nu .(plueckerVector), weighted_polyhedral_complex_only= weighted_polyhedral_complex_only)
197
197
198
198
if ! weighted_polyhedral_complex_only
199
199
set_attribute! (TropL,:algebraic_pluecker_vector ,plueckerVector)
@@ -209,7 +209,7 @@ function compute_pluecker_indices_and_vector(A::MatElem)
209
209
n = ncols (A)
210
210
k = nrows (A)
211
211
@req n>= k " matrix for Pluecker vector cannot have more rows than columns"
212
- plueckerIndices = AbstractAlgebra. combinations (1 : n,k)
212
+ plueckerIndices = AbstractAlgebra. combinations (n,k)
213
213
plueckerVector = AbstractAlgebra. minors (A,k)
214
214
nonZeroIndices = findall (! iszero,plueckerVector)
215
215
plueckerIndices = plueckerIndices[nonZeroIndices]
@@ -393,26 +393,22 @@ end
393
393
pluecker_indices(TropL::TropicalLinearSpace)
394
394
395
395
Return the Pluecker indices used to construct `TropL`.
396
+ Raises an error if neither it, nor any relevant algebraic data nor a tropical matrix is cached.
396
397
"""
397
398
@attr Vector{Vector{Int}} function pluecker_indices (TropL:: TropicalLinearSpace )
398
- # there are two ways to compute the pluecker indices:
399
- # - from the algebraic matrix
400
- # - from the tropical matrix
401
- # (we generally assume that a tropical linear space has at most one of the two)
402
-
403
- # check if tropical matrix is available and, if yes, compute the pluecker indices from it
404
- if has_attribute (TropL,:tropical_matrix )
405
- A = tropical_matrix (TropL)
399
+ # if any relevant algebraic data is cached, use it to construct the Pluecker indices
400
+ if any (has_attribute .(Ref (TropL),[:algebraic_matrix , :algebraic_ideal ]))
401
+ A = algebraic_matrix (TropL)
406
402
plueckerIndices, plueckerVector = compute_pluecker_indices_and_vector (A)
407
- set_attribute! (TropL, :tropical_pluecker_vector , plueckerVector)
403
+ set_attribute! (TropL, :algebraic_pluecker_vector , plueckerVector)
408
404
return plueckerIndices
409
405
end
410
406
411
- # otherwise, get the algebraic matrix and compute the pluecker indices from it
412
- # (will rightfully error if algebraic matrix cannot be found or computed )
413
- A = algebraic_matrix (TropL)
407
+ # otherwise use the tropical matrix to construct the Pluecker indices
408
+ # (will rightfully error if tropical matrix not cached )
409
+ A = tropical_matrix (TropL)
414
410
plueckerIndices, plueckerVector = compute_pluecker_indices_and_vector (A)
415
- set_attribute! (TropL, :algebraic_pluecker_vector , plueckerVector)
411
+ set_attribute! (TropL, :tropical_pluecker_vector , plueckerVector)
416
412
return plueckerIndices
417
413
end
418
414
421
417
tropical_pluecker_vector(TropL::TropicalLinearSpace)
422
418
423
419
Return the tropical Pluecker vector of `TropL`.
420
+ Reises an error if neither it, nor any algebraic data nor a tropical matrix is cached.
424
421
"""
425
422
@attr Vector function tropical_pluecker_vector (TropL:: TropicalLinearSpace )
423
+ # if any algebraic data is cached, use it to compute the tropical Pluecker vector.
424
+ if any (has_attribute .(Ref (TropL),[:algebraic_pluecker_vector , :algebraic_matrix , :algebraic_ideal ]))
425
+ algebraicPlueckerVector = algebraic_pluecker_vector (TropL)
426
+ nu = tropical_semiring_map (TropL)
427
+ return nu .(algebraicPlueckerVector)
428
+ end
429
+
430
+ # otherwise use tropical matrix to construct the tropical Pluecker vector
431
+ # (will rightfully error if tropical matrix not cached)
426
432
A = tropical_matrix (TropL)
427
433
plueckerIndices, plueckerVector = compute_pluecker_indices_and_vector (A)
428
434
set_attribute! (TropL, :pluecker_indices , plueckerIndices)
434
440
algebraic_pluecker_vector(TropL::TropicalLinearSpace)
435
441
436
442
Return the Pluecker vector over a valued field used to construct `TropL`.
443
+ Raises an error, if neither it nor an algebraic matrix nor an algebraic ideal is cached.
437
444
"""
438
445
@attr Vector function algebraic_pluecker_vector (TropL:: TropicalLinearSpace )
439
446
A = algebraic_matrix (TropL)
448
455
449
456
Return the tropical semiring map used to construct `TropL`. Raises an error, if it is not cached.
450
457
"""
451
- function tropical_semiring_map (TropL:: TropicalLinearSpace )
452
- @req has_attribute (TropL,:tropical_semiring_map ) " no tropical semiring map cached"
453
- return get_attribute (TropL, :tropical_semiring_map ):: TropicalSemiringMap
458
+ @attr TropicalSemiringMap function tropical_semiring_map (TropL:: TropicalLinearSpace )
459
+ error (" no tropical semiring map cached" )
454
460
end
455
461
456
462
@@ -459,27 +465,20 @@ end
459
465
460
466
Return the tropical matrix used to construct `TropL`. Raises an error, if it is not cached.
461
467
"""
462
- function tropical_matrix (TropL:: TropicalLinearSpace{minOrMax} ) where minOrMax
463
- if has_attribute (TropL,:tropical_matrix )
464
- return get_attribute (TropL, :tropical_matrix ):: dense_matrix_type (TropicalSemiringElem{minOrMax})
465
- end
466
- @req has_attribute (TropL,:algebraic_matrix ) && has_attribute (TropL,:tropical_semiring_map ) " neither tropical matrix nor algebraic matrix and tropical semiring map cached"
467
- A = algebraic_matrix (TropL)
468
- nu = tropical_semiring_map (TropL)
469
- return nu .(A)
468
+ @attr MatElem function tropical_matrix (TropL:: TropicalLinearSpace )
469
+ error (" no tropical matrix cached" )
470
470
end
471
471
472
472
473
473
@doc raw """
474
474
algebraic_matrix(TropL::TropicalLinearSpace)
475
475
476
476
Return the matrix over a valued field used to construct `TropL`.
477
+ Raises an error, if neither it nor an algebraic ideal is cached.
477
478
"""
478
479
@attr MatElem function algebraic_matrix (TropL:: TropicalLinearSpace )
479
- if has_attribute (TropL,:algebraic_matrix )
480
- return get_attribute (TropL, :algebraic_matrix ):: MatElem
481
- end
482
- @req has_attribute (TropL,:algebraic_ideal ) " neither algebraic matrix nor algebraic ideal cached"
480
+ # use algebraic ideal to construct the algebraic matrix
481
+ # (will rightfully error if algebraic ideal not defined)
483
482
I = algebraic_ideal (TropL)
484
483
return basis_of_vanishing_of_linear_ideal (I)
485
484
end
491
490
Return the polynomial ideal over a valued field used to construct `TropL`.
492
491
Raises an error, if it is not cached.
493
492
"""
494
- function algebraic_ideal (TropL:: TropicalLinearSpace )
495
- @req has_attribute (TropL,:algebraic_ideal ) " no algebraic ideal cached"
496
- return get_attribute (TropL, :algebraic_ideal ):: MPolyIdeal
493
+ @attr MPolyIdeal function algebraic_ideal (TropL:: TropicalLinearSpace )
494
+ error (" no algebraic ideal cached" )
497
495
end
0 commit comments