11//! Data structures for rsparse
2- //!
32
43use crate :: { add, multiply, scpmat, scxmat} ;
54use std:: fmt;
65use std:: fs:: File ;
7- use std:: io:: Write ;
8- use std:: io:: { BufRead , BufReader } ;
6+ use std:: io:: { BufRead , BufReader , Write } ;
97use std:: ops:: { Add , AddAssign , Div , DivAssign , Mul , MulAssign , Neg , Sub , SubAssign } ;
108
119// Define a generic Numeric trait compatible with `Sprs` matrices
@@ -120,14 +118,14 @@ pub trait Numeric<F>:
120118 + Default
121119 + Zero
122120 + One
121+ + Add < Output = F >
122+ + Sub < Output = F >
123+ + Mul < Output = F >
124+ + Div < Output = F >
125+ + Neg < Output = F >
126+ + std:: iter:: Sum
123127 + fmt:: Display
124128 + fmt:: Debug
125- + std:: ops:: Add < Output = F >
126- + std:: ops:: Sub < Output = F >
127- + std:: ops:: Mul < Output = F >
128- + std:: ops:: Div < Output = F >
129- + std:: ops:: Neg < Output = F >
130- + std:: iter:: Sum
131129 + From < F >
132130{
133131 fn abs ( self ) -> F ;
@@ -526,7 +524,7 @@ impl<T: Numeric<T>> Default for Sprs<T> {
526524
527525// Implementing operators for `Sprs`
528526
529- impl < T : Numeric < T > > std :: ops :: Add for Sprs < T > {
527+ impl < T : Numeric < T > > Add for Sprs < T > {
530528 type Output = Self ;
531529
532530 /// Overloads the `+` operator. Adds two sparse matrices
@@ -536,7 +534,7 @@ impl<T: Numeric<T>> std::ops::Add for Sprs<T> {
536534 }
537535}
538536
539- impl < T : Numeric < T > > std :: ops :: Add < & Sprs < T > > for Sprs < T > {
537+ impl < T : Numeric < T > > Add < & Sprs < T > > for Sprs < T > {
540538 type Output = Self ;
541539
542540 /// Overloads the `+` operator.
@@ -546,7 +544,7 @@ impl<T: Numeric<T>> std::ops::Add<&Sprs<T>> for Sprs<T> {
546544 }
547545}
548546
549- impl < T : Numeric < T > > std :: ops :: Add for & Sprs < T > {
547+ impl < T : Numeric < T > > Add for & Sprs < T > {
550548 type Output = Sprs < T > ;
551549
552550 /// Overloads the `+` operator. Adds two references to sparse matrices
@@ -556,7 +554,7 @@ impl<T: Numeric<T>> std::ops::Add for &Sprs<T> {
556554 }
557555}
558556
559- impl < T : Numeric < T > > std :: ops :: Add < Sprs < T > > for & Sprs < T > {
557+ impl < T : Numeric < T > > Add < Sprs < T > > for & Sprs < T > {
560558 type Output = Sprs < T > ;
561559
562560 /// Overloads the `+` operator.
@@ -566,7 +564,7 @@ impl<T: Numeric<T>> std::ops::Add<Sprs<T>> for &Sprs<T> {
566564 }
567565}
568566
569- impl < T : Numeric < T > > std :: ops :: Sub for Sprs < T > {
567+ impl < T : Numeric < T > > Sub for Sprs < T > {
570568 type Output = Self ;
571569
572570 /// Overloads the `-` operator. Subtracts two sparse matrices
@@ -576,7 +574,7 @@ impl<T: Numeric<T>> std::ops::Sub for Sprs<T> {
576574 }
577575}
578576
579- impl < T : Numeric < T > > std :: ops :: Sub < & Sprs < T > > for Sprs < T > {
577+ impl < T : Numeric < T > > Sub < & Sprs < T > > for Sprs < T > {
580578 type Output = Self ;
581579
582580 /// Overloads the `-` operator.
@@ -586,7 +584,7 @@ impl<T: Numeric<T>> std::ops::Sub<&Sprs<T>> for Sprs<T> {
586584 }
587585}
588586
589- impl < T : Numeric < T > > std :: ops :: Sub for & Sprs < T > {
587+ impl < T : Numeric < T > > Sub for & Sprs < T > {
590588 type Output = Sprs < T > ;
591589
592590 /// Overloads the `-` operator. Subtracts two references to sparse matrices
@@ -596,7 +594,7 @@ impl<T: Numeric<T>> std::ops::Sub for &Sprs<T> {
596594 }
597595}
598596
599- impl < T : Numeric < T > > std :: ops :: Sub < Sprs < T > > for & Sprs < T > {
597+ impl < T : Numeric < T > > Sub < Sprs < T > > for & Sprs < T > {
600598 type Output = Sprs < T > ;
601599
602600 /// Overloads the `-` operator.
@@ -606,7 +604,7 @@ impl<T: Numeric<T>> std::ops::Sub<Sprs<T>> for &Sprs<T> {
606604 }
607605}
608606
609- impl < T : Numeric < T > > std :: ops :: Mul for Sprs < T > {
607+ impl < T : Numeric < T > > Mul for Sprs < T > {
610608 type Output = Self ;
611609
612610 /// Overloads the `*` operator. Multiplies two sparse matrices
@@ -616,7 +614,7 @@ impl<T: Numeric<T>> std::ops::Mul for Sprs<T> {
616614 }
617615}
618616
619- impl < T : Numeric < T > > std :: ops :: Mul < & Sprs < T > > for Sprs < T > {
617+ impl < T : Numeric < T > > Mul < & Sprs < T > > for Sprs < T > {
620618 type Output = Self ;
621619
622620 /// Overloads the `*` operator.
@@ -626,7 +624,7 @@ impl<T: Numeric<T>> std::ops::Mul<&Sprs<T>> for Sprs<T> {
626624 }
627625}
628626
629- impl < T : Numeric < T > > std :: ops :: Mul for & Sprs < T > {
627+ impl < T : Numeric < T > > Mul for & Sprs < T > {
630628 type Output = Sprs < T > ;
631629
632630 /// Overloads the `*` operator. Multiplies two references to sparse matrices
@@ -636,7 +634,7 @@ impl<T: Numeric<T>> std::ops::Mul for &Sprs<T> {
636634 }
637635}
638636
639- impl < T : Numeric < T > > std :: ops :: Mul < Sprs < T > > for & Sprs < T > {
637+ impl < T : Numeric < T > > Mul < Sprs < T > > for & Sprs < T > {
640638 type Output = Sprs < T > ;
641639
642640 /// Overloads the `*` operator.
@@ -648,7 +646,7 @@ impl<T: Numeric<T>> std::ops::Mul<Sprs<T>> for &Sprs<T> {
648646
649647// Implementing operators for `Sprs` and `T` types
650648
651- impl < T : Numeric < T > > std :: ops :: Add < T > for Sprs < T > {
649+ impl < T : Numeric < T > > Add < T > for Sprs < T > {
652650 type Output = Self ;
653651
654652 /// Overloads the `+` operator. Adds an `T` value to all elements of a
@@ -659,7 +657,7 @@ impl<T: Numeric<T>> std::ops::Add<T> for Sprs<T> {
659657 }
660658}
661659
662- impl < T : Numeric < T > > std :: ops :: Add < T > for & Sprs < T > {
660+ impl < T : Numeric < T > > Add < T > for & Sprs < T > {
663661 type Output = Sprs < T > ;
664662
665663 /// Overloads the `+` operator. Adds an `T` value to all elements of a
@@ -670,7 +668,7 @@ impl<T: Numeric<T>> std::ops::Add<T> for &Sprs<T> {
670668 }
671669}
672670
673- impl < T : Numeric < T > > std :: ops :: Sub < T > for Sprs < T > {
671+ impl < T : Numeric < T > > Sub < T > for Sprs < T > {
674672 type Output = Self ;
675673
676674 /// Overloads the `-` operator. Subtracts an `T` value to all elements of
@@ -681,7 +679,7 @@ impl<T: Numeric<T>> std::ops::Sub<T> for Sprs<T> {
681679 }
682680}
683681
684- impl < T : Numeric < T > > std :: ops :: Sub < T > for & Sprs < T > {
682+ impl < T : Numeric < T > > Sub < T > for & Sprs < T > {
685683 type Output = Sprs < T > ;
686684
687685 /// Overloads the `-` operator. Subtracts an `T` value to all elements of
@@ -692,7 +690,7 @@ impl<T: Numeric<T>> std::ops::Sub<T> for &Sprs<T> {
692690 }
693691}
694692
695- impl < T : Numeric < T > > std :: ops :: Mul < T > for Sprs < T > {
693+ impl < T : Numeric < T > > Mul < T > for Sprs < T > {
696694 type Output = Self ;
697695
698696 /// Overloads the `*` operator. Multiplies an `T` value to all elements of
@@ -703,7 +701,7 @@ impl<T: Numeric<T>> std::ops::Mul<T> for Sprs<T> {
703701 }
704702}
705703
706- impl < T : Numeric < T > > std :: ops :: Mul < T > for & Sprs < T > {
704+ impl < T : Numeric < T > > Mul < T > for & Sprs < T > {
707705 type Output = Sprs < T > ;
708706
709707 /// Overloads the `*` operator. Multiplies an `T` value to all elements of
@@ -714,7 +712,7 @@ impl<T: Numeric<T>> std::ops::Mul<T> for &Sprs<T> {
714712 }
715713}
716714
717- impl < T : Numeric < T > > std :: ops :: Div < T > for Sprs < T > {
715+ impl < T : Numeric < T > > Div < T > for Sprs < T > {
718716 type Output = Self ;
719717
720718 /// Overloads the `/` operator. Divides by an `T` value to all elements of
@@ -725,7 +723,7 @@ impl<T: Numeric<T>> std::ops::Div<T> for Sprs<T> {
725723 }
726724}
727725
728- impl < T : Numeric < T > > std :: ops :: Div < T > for & Sprs < T > {
726+ impl < T : Numeric < T > > Div < T > for & Sprs < T > {
729727 type Output = Sprs < T > ;
730728
731729 /// Overloads the `/` operator. Divides by an `T` value to all elements of
@@ -738,7 +736,7 @@ impl<T: Numeric<T>> std::ops::Div<T> for &Sprs<T> {
738736
739737// Implementing operators for `T` and `Sprs<T>` types
740738
741- // impl <T: Numeric<T>> std::ops:: Add<Sprs<T>> for T {
739+ // impl <T: Numeric<T>> Add<Sprs<T>> for T {
742740// type Output = Sprs<T>;
743741
744742// /// Overloads the `+` operator. Adds an `T` value to all elements of a
@@ -749,7 +747,7 @@ impl<T: Numeric<T>> std::ops::Div<T> for &Sprs<T> {
749747// }
750748// }
751749
752- // impl <T: Numeric<T>> std::ops:: Add<&Sprs<T>> for T {
750+ // impl <T: Numeric<T>> Add<&Sprs<T>> for T {
753751// type Output = Sprs<T>;
754752
755753// /// Overloads the `+` operator. Adds an `T` value to all elements of a
@@ -760,7 +758,7 @@ impl<T: Numeric<T>> std::ops::Div<T> for &Sprs<T> {
760758// }
761759// }
762760
763- // impl <T: Numeric<T>> std::ops:: Sub<Sprs<T>> for T {
761+ // impl <T: Numeric<T>> Sub<Sprs<T>> for T {
764762// type Output = Sprs<T>;
765763
766764// /// Overloads the `-` operator. Subtracts an `T` value to all elements of
@@ -771,7 +769,7 @@ impl<T: Numeric<T>> std::ops::Div<T> for &Sprs<T> {
771769// }
772770// }
773771
774- // impl <T: Numeric<T>> std::ops:: Sub<&Sprs<T>> for T {
772+ // impl <T: Numeric<T>> Sub<&Sprs<T>> for T {
775773// type Output = Sprs<T>;
776774
777775// /// Overloads the `-` operator. Subtracts an `T` value to all elements of
@@ -782,7 +780,7 @@ impl<T: Numeric<T>> std::ops::Div<T> for &Sprs<T> {
782780// }
783781// }
784782
785- // impl <T: Numeric<T>> std::ops:: Mul<Sprs<T>> for T {
783+ // impl <T: Numeric<T>> Mul<Sprs<T>> for T {
786784// type Output = Sprs<T>;
787785
788786// /// Overloads the `*` operator. Multiplies an `T` value to all elements of
@@ -793,7 +791,7 @@ impl<T: Numeric<T>> std::ops::Div<T> for &Sprs<T> {
793791// }
794792// }
795793
796- // impl <T: Numeric<T>> std::ops:: Mul<&Sprs<T>> for T {
794+ // impl <T: Numeric<T>> Mul<&Sprs<T>> for T {
797795// type Output = Sprs<T>;
798796
799797// /// Overloads the `*` operator. Multiplies an `T` value to all elements of
0 commit comments