Changeset 188cfbd in git
- Timestamp:
- Apr 17, 2015, 2:45:34 PM (8 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- f52bd59412a399cb6c4ca21c965dd68c19aa5def
- Parents:
- 7203f75e9a4e317e9e009db8a853ed8c0e6be6357cb9b47e0c889244f467795deb33c7c8156369b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/standard.lib
r7203f7 r188cfbd 17 17 par2varRing([i]) create a ring making pars to vars, together with i 18 18 datetime() return date and time as a string 19 max(i ,j) maximum of i and j20 min(i ,j) minimum of i and j19 max(i_1,...,i_k) maximum of i_1, ..., i_k 20 min(i_1,...,i_k) minimum of i_1, ..., i_k 21 21 22 22 "; … … 2185 2185 2186 2186 /////////////////////////////////////////////////////////////////////////////// 2187 proc max(def i, def j)2188 "SYNTAX: max (i , j)2189 TYPE: same as type of i resp. j2190 PURPOSE: returns the maximum for any 2arguments of a type2187 proc max(def i,list #) 2188 "SYNTAX: max (i_1, ..., i_k) 2189 TYPE: same as type of i_1, ..., i_k resp. 2190 PURPOSE: returns the maximum for any arguments of a type 2191 2191 for which '>' is defined 2192 2192 SEE ALSO: min 2193 2193 EXAMPLE: example max; shows an example" 2194 2194 { 2195 if(i>j){return(i);} 2196 return(j); 2195 def maximum = i; 2196 for (int j=1; j<=size(#); j++) 2197 { 2198 if(#[j]>maximum) 2199 { 2200 maximum = #[j]; 2201 } 2202 } 2203 return(maximum); 2197 2204 } 2198 2205 example 2199 2206 { "EXAMPLE:"; echo=2; 2207 // biggest int 2200 2208 max(2,3); 2201 max(4,3); 2209 max(1,4,3); 2210 // lexicographically biggest intvec 2211 max(intvec(1,2),intvec(0,1),intvec(1,1)); 2212 // polynopmial with biggest leading monomial 2213 ring r = 0,x,dp; 2214 max(x+1,x2+x); 2202 2215 } 2203 2216 /////////////////////////////////////////////////////////////////////////////// 2204 proc min(def i, def j)2205 "SYNTAX: min (i , j)2206 TYPE: same as type of i resp. j2207 PURPOSE: returns the minimum for any 2arguments of a type2217 proc min(def i,list #) 2218 "SYNTAX: min (i_1, ..., i_k) 2219 TYPE: same as type of i_1, ..., i_k resp. 2220 PURPOSE: returns the minimum for any arguments of a type 2208 2221 for which '>' is defined 2209 2222 SEE ALSO: max 2210 2223 EXAMPLE: example min; shows an example" 2211 2224 { 2212 if(i>j){return(j);} 2213 return(i); 2225 def minimum = i; 2226 for (int j=1; j<=size(#); j++) 2227 { 2228 if(#[j]<minimum) 2229 { 2230 minimum = #[j]; 2231 } 2232 } 2233 return(minimum); 2214 2234 } 2215 2235 example 2216 2236 { "EXAMPLE:"; echo=2; 2237 // smallest int 2217 2238 min(2,3); 2218 min(4,3); 2239 min(1,4,3); 2240 // lexicographically smallest intvec 2241 min(intvec(1,2),intvec(0,1),intvec(1,1)); 2242 // polynopmial with smallest leading monomial 2243 ring r = 0,x,dp; 2244 min(x+1,x2+x); 2219 2245 } 2220 2246
Note: See TracChangeset
for help on using the changeset viewer.