svf-lib 1.0.1714 → 1.0.1716

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.
@@ -575,74 +575,100 @@ inline IntervalValue operator%(const IntervalValue &lhs,
575
575
  }
576
576
  }
577
577
 
578
- /// Greater than IntervalValues
578
+ // Compare two IntervalValues for greater than
579
579
  inline IntervalValue operator>(const IntervalValue &lhs, const IntervalValue &rhs)
580
580
  {
581
+ // If either lhs or rhs is bottom, the result is bottom
581
582
  if (lhs.isBottom() || rhs.isBottom())
582
583
  {
583
584
  return IntervalValue::bottom();
584
585
  }
585
- else if (lhs.isTop() || lhs.isTop())
586
+ // If either lhs or rhs is top, the result is top
587
+ else if (lhs.isTop() || rhs.isTop())
586
588
  {
587
589
  return IntervalValue::top();
588
590
  }
589
591
  else
590
592
  {
593
+ // If both lhs and rhs are numerals (lb = ub), directly compare their values
591
594
  if (lhs.is_numeral() && rhs.is_numeral())
592
595
  {
596
+ // It means lhs.lb() > rhs.lb()? true: false
593
597
  return lhs.lb().leq(rhs.lb()) ? IntervalValue(0, 0) : IntervalValue(1, 1);
594
598
  }
595
599
  else
596
600
  {
597
- // lhs[3,4] rhs[1,2]
601
+ // Return [1,1] means lhs is totally greater than rhs
602
+ // When lhs.lb > rhs.ub, e.g., lhs:[3, 4] rhs:[1, 2]
603
+ // lhs.lb(3) > rhs.ub(2)
604
+ // It means lhs.lb() > rhs.ub()
598
605
  if (!lhs.lb().leq(rhs.ub()))
599
606
  {
600
607
  return IntervalValue(1, 1);
601
- // lhs[1,2] rhs[3,4]
602
608
  }
603
- else if (!lhs.ub().geq(rhs.lb()))
609
+ // Return [0,0] means lhs is totally impossible to be greater than rhs
610
+ // i.e., lhs is totally less than or equal to rhs
611
+ // When lhs.ub <= rhs.lb, e.g., lhs:[3, 4] rhs:[4,5]
612
+ // lhs.ub(4) <= rhs.lb(4)
613
+ else if (lhs.ub().leq(rhs.lb()))
604
614
  {
605
615
  return IntervalValue(0, 0);
606
616
  }
617
+ // For other cases, lhs can be greater than or not, depending on the values
618
+ // e.g., lhs: [2,4], rhs: [1,3],
619
+ // lhs can be greater than rhs if lhs is 4 and rhs is 1.
620
+ // lhs can also not be greater than rhs if lhs is 2 and rhs is 3
607
621
  else
608
622
  {
609
- // lhs[1,3] rhs[2,4]
610
623
  return IntervalValue(0, 1);
611
624
  }
612
625
  }
613
626
  }
614
627
  }
615
628
 
616
- /// Greater than IntervalValues
629
+ // Compare two IntervalValues for less than
617
630
  inline IntervalValue operator<(const IntervalValue &lhs, const IntervalValue &rhs)
618
631
  {
632
+ // If either lhs or rhs is bottom, the result is bottom
619
633
  if (lhs.isBottom() || rhs.isBottom())
620
634
  {
621
635
  return IntervalValue::bottom();
622
636
  }
623
- else if (lhs.isTop() || lhs.isTop())
637
+ // If either lhs or rhs is top, the result is top
638
+ else if (lhs.isTop() || rhs.isTop())
624
639
  {
625
640
  return IntervalValue::top();
626
641
  }
627
642
  else
628
643
  {
644
+ // If both lhs and rhs are numerals (lb = ub), directly compare their values
629
645
  if (lhs.is_numeral() && rhs.is_numeral())
630
646
  {
647
+ // It means lhs.lb() < rhs.lb()? true: false
631
648
  return lhs.lb().geq(rhs.lb()) ? IntervalValue(0, 0) : IntervalValue(1, 1);
632
649
  }
633
650
  else
634
651
  {
635
- // lhs [1,2] rhs [3,4]
652
+ // Return [1,1] means lhs is totally less than rhs
653
+ // When lhs.ub < rhs.lb, e.g., lhs:[1, 2] rhs:[3, 4]
654
+ // lhs.ub(2) < rhs.lb(3)
655
+ // It means lhs.ub() < rhs.lb()
636
656
  if (!lhs.ub().geq(rhs.lb()))
637
657
  {
638
658
  return IntervalValue(1, 1);
639
- // lhs [3,4] rhs [1,2]
640
659
  }
641
- else if (!lhs.lb().leq(rhs.ub()))
660
+ // Return [0,0] means lhs is totally impossible to be less than rhs
661
+ // i.e., lhs is totally greater than or equal to rhs
662
+ // When lhs.ub >= rhs.lb, e.g., lhs:[3, 4] rhs:[4,5]
663
+ // lhs.ub(4) >= rhs.lb(4)
664
+ else if (rhs.ub().geq(lhs.lb()))
642
665
  {
643
666
  return IntervalValue(0, 0);
644
- // lhs [1,3] rhs [2,4]
645
667
  }
668
+ // For other cases, lhs can be less than rhs or not, depending on the values
669
+ // e.g., lhs: [2,4], rhs: [1,3],
670
+ // lhs can be less than rhs if lhs is 2, rhs is 3.
671
+ // lhs can also not be less than rhs if lhs is 4 and rhs is 1
646
672
  else
647
673
  {
648
674
  return IntervalValue(0, 1);
@@ -651,79 +677,101 @@ inline IntervalValue operator<(const IntervalValue &lhs, const IntervalValue &rh
651
677
  }
652
678
  }
653
679
 
654
- /// Greater than IntervalValues
680
+ // Compare two IntervalValues for greater than or equal to
655
681
  inline IntervalValue operator>=(const IntervalValue &lhs, const IntervalValue &rhs)
656
682
  {
683
+ // If either lhs or rhs is bottom, the result is bottom
657
684
  if (lhs.isBottom() || rhs.isBottom())
658
685
  {
659
686
  return IntervalValue::bottom();
660
687
  }
661
- else if (lhs.isTop() || lhs.isTop())
688
+ // If either lhs or rhs is top, the result is top
689
+ else if (lhs.isTop() || rhs.isTop())
662
690
  {
663
691
  return IntervalValue::top();
664
692
  }
665
693
  else
666
694
  {
695
+ // If both lhs and rhs are numerals (lb = ub), directly compare their values
667
696
  if (lhs.is_numeral() && rhs.is_numeral())
668
697
  {
669
698
  return lhs.lb().geq(rhs.lb()) ? IntervalValue(1, 1) : IntervalValue(0, 0);
670
699
  }
671
700
  else
672
701
  {
673
- // lhs [2,3] rhs [1,2]
702
+ // Return [1,1] means lhs is totally greater than or equal to rhs
703
+ // When lhs.lb >= rhs.ub, e.g., lhs:[2, 3] rhs:[1, 2]
704
+ // lhs.lb(2) >= rhs.ub(2)
674
705
  if (lhs.lb().geq(rhs.ub()))
675
706
  {
676
707
  return IntervalValue(1, 1);
677
- // lhs [1,2] rhs[3,4]
678
708
  }
709
+ // Return [0,0] means lhs is totally impossible to be greater than or equal to rhs
710
+ // i.e., lhs is totally less than rhs
711
+ // When lhs.ub < rhs.lb, e.g., lhs:[1, 2] rhs:[3, 4]
712
+ // lhs.ub(2) < rhs.lb(3)
713
+ // It means lhs.ub() < rhs.lb()
679
714
  else if (!lhs.ub().geq(rhs.lb()))
680
715
  {
681
716
  return IntervalValue(0, 0);
682
- // lhs [1,3] rhs [2,4]
683
717
  }
718
+ // For other cases, lhs can be greater than or equal to rhs or not, depending on the values
719
+ // e.g., lhs: [2,4], rhs: [1,3],
720
+ // lhs can be greater than or equal to rhs if lhs is 3, rhs is 2.
721
+ // lhs can also not be greater than or equal to rhs if lhs is 2 and rhs is 3
684
722
  else
685
723
  {
686
- if (lhs.equals(rhs)) return IntervalValue(1, 1);
687
- else return IntervalValue(0, 1);
724
+ return IntervalValue(0, 1);
688
725
  }
689
726
  }
690
727
  }
691
728
  }
692
729
 
693
- /// Greater than IntervalValues
730
+ // Compare two IntervalValues for less than or equal to
694
731
  inline IntervalValue operator<=(const IntervalValue &lhs, const IntervalValue &rhs)
695
732
  {
733
+ // If either lhs or rhs is bottom, the result is bottom
696
734
  if (lhs.isBottom() || rhs.isBottom())
697
735
  {
698
736
  return IntervalValue::bottom();
699
737
  }
700
- else if (lhs.isTop() || lhs.isTop())
738
+ // If either lhs or rhs is top, the result is top
739
+ else if (lhs.isTop() || rhs.isTop())
701
740
  {
702
741
  return IntervalValue::top();
703
742
  }
704
743
  else
705
744
  {
745
+ // If both lhs and rhs are numerals (lb = ub), directly compare their values
706
746
  if (lhs.is_numeral() && rhs.is_numeral())
707
747
  {
708
748
  return lhs.lb().leq(rhs.lb()) ? IntervalValue(1, 1) : IntervalValue(0, 0);
709
749
  }
710
750
  else
711
751
  {
712
- // lhs [1,2] rhs [2,3]
752
+ // Return [1,1] means lhs is totally less than or equal to rhs
753
+ // When lhs.ub <= rhs.lb, e.g., lhs:[1, 2] rhs:[2, 3]
754
+ // lhs.ub(2) <= rhs.lb(2)
713
755
  if (lhs.ub().leq(rhs.lb()))
714
756
  {
715
757
  return IntervalValue(1, 1);
716
- // lhs [3,4] rhs[1,2]
717
758
  }
759
+ // Return [0,0] means lhs is totally impossible to be less than or equal to rhs
760
+ // i.e., lhs is totally greater than rhs
761
+ // When lhs.lb > rhs.ub, e.g., lhs:[3, 4] rhs:[1, 2]
762
+ // lhs.lb(3) > rhs.ub(2)
763
+ // It means lhs.lb() > rhs.ub()
718
764
  else if (!lhs.lb().leq(rhs.ub()))
719
765
  {
720
766
  return IntervalValue(0, 0);
721
- // lhs [1,3] rhs [2,4]
722
767
  }
768
+ // For other cases, lhs can be less than or equal to rhs or not, depending on the values
769
+ // e.g., lhs: [2,4], rhs: [1,3],
770
+ // lhs can be less than or equal to rhs if lhs is 3, rhs is 3.
771
+ // lhs can also not be less than or equal to rhs if lhs is 3 and rhs is 2
723
772
  else
724
773
  {
725
- if (lhs.equals(rhs)) return IntervalValue(1, 1);
726
- else return IntervalValue(0, 1);
774
+ return IntervalValue(0, 1);
727
775
  }
728
776
  }
729
777
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1714",
3
+ "version": "1.0.1716",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {