@@ -767,4 +767,87 @@ def subst_into_pwaff(new_space, pwaff, subst_dict):
767
767
768
768
# }}}
769
769
770
+
771
+ # {{{ add_and_name_dims
772
+
773
+ def add_and_name_dims (isl_obj , dt , names ):
774
+ """Append dimensions of the specified dimension type to the provided ISL
775
+ object, and set their names.
776
+
777
+ :arg isl_obj: An :class:`islpy.Set` or :class:`islpy.Map` to which
778
+ new dimensions will be added.
779
+
780
+ :arg dt: An :class:`islpy.dim_type`, i.e., an :class:`int`, specifying the
781
+ dimension type for the new dimensions.
782
+
783
+ :arg names: An iterable of :class:`str` values specifying the names of the
784
+ new dimensions to be added.
785
+
786
+ :returns: An object of the same type as *isl_obj* with the new dimensions
787
+ added and named.
788
+
789
+ """
790
+
791
+ new_idx_start = isl_obj .dim (dt )
792
+ isl_obj = isl_obj .add_dims (dt , len (names ))
793
+ for i , name in enumerate (names ):
794
+ isl_obj = isl_obj .set_dim_name (dt , new_idx_start + i , name )
795
+ return isl_obj
796
+
797
+ # }}}
798
+
799
+
800
+ # {{{ add_eq_constraint_from_names
801
+
802
+ def add_eq_constraint_from_names (isl_obj , var1 , var2 ):
803
+ """Add constraint *var1* = *var2* to an ISL object.
804
+
805
+ :arg isl_obj: An :class:`islpy.Set` or :class:`islpy.Map` to which
806
+ a new constraint will be added.
807
+
808
+ :arg var1: A :class:`str` specifying the name of the first variable
809
+ involved in constraint *var1* = *var2*.
810
+
811
+ :arg var2: A :class:`str` specifying the name of the second variable
812
+ involved in constraint *var1* = *var2*.
813
+
814
+ :returns: An object of the same type as *isl_obj* with the constraint
815
+ *var1* = *var2*.
816
+
817
+ """
818
+ return isl_obj .add_constraint (
819
+ isl .Constraint .eq_from_names (
820
+ isl_obj .space ,
821
+ {1 : 0 , var1 : 1 , var2 : - 1 }))
822
+
823
+ # }}}
824
+
825
+
826
+ # {{{ find_and_rename_dim
827
+
828
+ def find_and_rename_dim (isl_obj , dt , old_name , new_name ):
829
+ """Rename a dimension in an ISL object.
830
+
831
+ :arg isl_obj: An :class:`islpy.Set` or :class:`islpy.Map` containing the
832
+ dimension to be renamed.
833
+
834
+ :arg dt: An :class:`islpy.dim_type` (i.e., :class:`int`) specifying the
835
+ dimension type containing the dimension to be renamed.
836
+
837
+ :arg old_name: A :class:`str` specifying the name of the dimension to be
838
+ renamed.
839
+
840
+ :arg new_name: A :class:`str` specifying the new name of the dimension to
841
+ be renamed.
842
+
843
+ :returns: An object of the same type as *isl_obj* with the dimension
844
+ *old_name* renamed to *new_name*.
845
+
846
+ """
847
+ return isl_obj .set_dim_name (
848
+ dt , isl_obj .find_dim_by_name (dt , old_name ), new_name )
849
+
850
+ # }}}
851
+
852
+
770
853
# vim: foldmethod=marker
0 commit comments