1Math_arithmetic_item = class
2	Menupullright "_Arithmetic" "basic arithmetic for objects" {
3	Add_item = class
4		Menuaction "_Add" "add a and b" {
5		action a b = map_binary add a b;
6	}
7
8	Subtract_item = class
9		Menuaction "_Subtract" "subtract b from a" {
10		action a b = map_binary subtract a b;
11	}
12
13	Multiply_item = class
14		Menuaction "_Multiply" "multiply a by b" {
15		action a b = map_binary multiply a b;
16	}
17
18	Divide_item = class
19		Menuaction "_Divide" "divide a by b" {
20		action a b = map_binary divide a b;
21	}
22
23	Remainder_item = class
24		Menuaction "_Remainder"
25			"remainder after integer division of a by b" {
26		action a b = map_binary remainder a b;
27	}
28
29	sep1 = Menuseparator;
30
31	Absolute_value_item = class
32		Menuaction "A_bsolute Value" "absolute value of x" {
33		action x = map_unary abs x;
34	}
35
36	Absolute_value_vector_item = class
37		Menuaction "Absolute Value _Vector"
38			"like Absolute Value, but treat pixels as vectors" {
39		action x = map_unary abs_vec x;
40	}
41
42	Sign_item = class
43		Menuaction "S_ign" "unit vector" {
44		action x = map_unary sign x;
45	}
46
47	Negate_item = class
48		Menuaction "_Negate" "multiply by -1" {
49		action x = map_unary unary_minus x;
50	}
51}
52
53Math_trig_item = class
54	Menupullright "_Trigonometry" "trigonometry operations (all in degrees)" {
55	Sin_item = class
56		Menuaction "_Sine" "calculate sine x" {
57		action x = map_unary sin x;
58	}
59
60	Cos_item = class
61		Menuaction "_Cosine" "calculate cosine x" {
62		action x = map_unary cos x;
63	}
64
65	Tan_item = class
66		Menuaction "_Tangent" "calculate tangent x" {
67		action x = map_unary tan x;
68	}
69
70	sep1 = Menuseparator;
71
72	Asin_item = class
73		Menuaction "Arc S_ine" "calculate arc sine x" {
74		action x = map_unary asin x;
75	}
76
77	Acos_item = class
78		Menuaction "Arc C_osine" "calculate arc cosine x" {
79		action x = map_unary acos x;
80	}
81
82	Atan_item = class
83		Menuaction "Arc T_angent" "calculate arc tangent x" {
84		action x = map_unary atan x;
85	}
86
87	sep2 = Menuseparator;
88
89	Rad_item = class
90		Menuaction "_Degrees to Radians" "convert degrees to radians" {
91		action x = map_unary rad x;
92	}
93
94	Deg_item = class
95		Menuaction "_Radians to Degrees" "convert radians to degrees" {
96		action x = map_unary deg x;
97	}
98
99	sep3 = Menuseparator;
100
101	Angle_range_item = class
102		Menuaction "Angle i_n Range"
103			"is angle within t degrees of r, mod 360" {
104		action t r angle
105		      =	clock (max - angle) < 2*r
106		{
107			max = clock (t + r);
108
109			clock a
110			      =	a + 360, a < 0;
111			      =	a - 360, a >= 360;
112			      = a;
113		}
114	}
115}
116
117Math_log_item = class
118	Menupullright "_Log" "logarithms and anti-logs" {
119	Exponential_item = class
120		Menuaction "_Exponential" "calculate e ** x" {
121		action x = map_unary (power e) x;
122	}
123
124	Log_natural_item = class
125		Menuaction "Natural _Log" "log base e of x" {
126		action x = map_unary log x;
127	}
128
129	sep1 = Menuseparator;
130
131	Exponential10_item = class
132		Menuaction "E_xponential base 10" "calculate 10 ** x" {
133		action x = map_unary (power 10) x;
134	}
135
136	Log10_item = class
137		Menuaction "L_og Base 10" "log base 10 of x" {
138		action x = map_unary log10 x;
139	}
140
141	sep2 = Menuseparator;
142
143	Raise_to_power_item = class
144		Menuaction "_Raise to Power" "calculate x ** y" {
145		action x y = map_binary power x y;
146	}
147}
148
149Math_complex_item = class
150	Menupullright "_Complex" "operations on complex numbers and images" {
151	Complex_extract = class
152		Menupullright "_Extract" "extract fields from complex" {
153		Real_item = class
154			Menuaction "_Real"
155				"extract real part of complex" {
156			action in = map_unary re in;
157		}
158
159		Imaginary_item = class
160			Menuaction "_Imaginary"
161				"extract imaginary part of complex" {
162			action in = map_unary im in;
163		}
164	}
165
166	Complex_build_item = class
167		Menuaction "_Build" "join a and b to make a complex" {
168		action a b = map_binary comma a b;
169	}
170
171	sep1 = Menuseparator;
172
173	Polar_item = class
174		Menuaction "_Polar"
175			"convert real and imag to amplitude and phase" {
176		action a = map_unary polar a;
177	}
178
179	Rectangular_item = class
180		Menuaction "_Rectagular"
181			("convert (amplitude, phase) image to rectangular " ++
182			"coordinates") {
183		action x = map_unary rectangular x;
184	}
185
186	sep2 = Menuseparator;
187
188	Conjugate_item = class
189		Menuaction "_Conjugate" "invert imaginary part" {
190		action x = map_unary conj x;
191	}
192}
193
194Math_boolean_item = class
195	Menupullright "_Boolean" "bitwise boolean operations for integer objects" {
196	And_item = class
197		Menuaction "_And" "bitwise and of a and b" {
198		action a b = map_binary bitwise_and a b;
199	}
200
201	Or_item = class
202		Menuaction "_Or" "bitwise or of a and b" {
203		action a b = map_binary bitwise_or a b;
204	}
205
206	Eor_item = class
207		Menuaction "E_xclusive Or" "bitwise exclusive or of a and b" {
208		action a b = map_binary eor a b;
209	}
210
211	Not_item = class
212		Menuaction "_Not" "invert a" {
213		action a = map_unary not a;
214	}
215
216	sep1 = Menuseparator;
217
218	Right_shift_item = class
219		Menuaction "Shift _Right" "shift a right by b bits" {
220		action a b = map_binary right_shift a b;
221	}
222
223	Left_shift_item = class
224		Menuaction "Shift _Left" "shift a left by b bits" {
225		action a b = map_binary left_shift a b;
226	}
227
228	sep2 = Menuseparator;
229
230	If_then_else_item = class
231		Menuaction "_If Then Else"
232			"b where a is non-zero, c elsewhere" {
233		action a b c = map_trinary if_then_else a b c;
234	}
235
236	Band_or_item = class
237		Menuaction "Band O_r" "or the bands of an image together" {
238		action im = map_unary (foldr1 bitwise_or @ bandsplit) im;
239	}
240
241	Band_and_item = class
242		Menuaction "Band A_nd" "and the bands of an image together" {
243		action im = map_unary (foldr1 bitwise_and @ bandsplit) im;
244	}
245}
246
247Math_relational_item = class
248	Menupullright "R_elational" "comparison operations" {
249	Equal_item = class
250		Menuaction "_Equal to" "test a equal to b" {
251		action a b = map_binary equal a b;
252	}
253
254	Not_equal_item = class
255		Menuaction "_Not Equal to" "test a not equal to b" {
256		action a b = map_binary not_equal a b;
257	}
258
259	sep1 = Menuseparator;
260
261	More_item = class
262		Menuaction "_More Than" "test a strictly greater than b" {
263		action a b = map_binary more a b;
264	}
265
266	Less_item = class
267		Menuaction "_Less Than" "test a strictly less than b" {
268		action a b = map_binary less a b;
269	}
270
271	sep2 = Menuseparator;
272
273	More_equal_item = class
274		Menuaction "M_ore Than or Equal to"
275			"test a greater than or equal to b" {
276		action a b = map_binary more_equal a b;
277	}
278
279	Less_equal_item = class
280		Menuaction "L_ess Than or Equal to"
281			"test a less than or equal to b" {
282		action a b = map_binary less_equal a b;
283	}
284}
285
286Math_list_item = class
287	Menupullright "L_ist" "operations on lists" {
288	Head_item = class
289		Menuaction "_Head" "first element in list" {
290		action x = hd x;
291	}
292
293	Tail_item = class
294		Menuaction "_Tail" "list without the first element" {
295		action x = tl x;
296	}
297
298	Last_item = class
299		Menuaction "_Last" "last element in list" {
300		action x = last x;
301	}
302
303	Init_item = class
304		Menuaction "_Init" "list without the last element" {
305		action x = init x;
306	}
307
308	sep1 = Menuseparator;
309
310	Reverse_item = class
311		Menuaction "_Reverse" "reverse order of elements in list" {
312		action x = reverse x;
313	}
314
315	Sort_item = class
316		Menuaction "_Sort" "sort list into ascending order" {
317		action x = sort x;
318	}
319
320	Make_set_item = class
321		Menuaction "_Make Set" "remove duplicates from list" {
322		action x = mkset equal x;
323	}
324
325	Transpose_list_item = class
326		Menuaction "Tr_anspose"
327			"exchange rows and columns in a list of lists" {
328		action x = transpose x;
329	}
330
331	Concat_item = class
332		Menuaction "_Concat"
333			"flatten a list of lists into a single list" {
334		action l = concat l;
335	}
336
337	sep2 = Menuseparator;
338
339	Length_item = class
340		Menuaction "L_ength" "find the length of list" {
341		action x = len x;
342	}
343
344	Subscript_item = class
345		Menuaction "S_ubscript"
346			"return element n from list (index from zero)" {
347		action n x = n ? x;
348	}
349
350	Take_item = class
351		Menuaction "_Take" "take the first n elements of list x" {
352		action n x = take n x;
353	}
354
355	Drop_item = class
356		Menuaction "_Drop" "drop the first n elements of list x" {
357		action n x = drop n x;
358	}
359
360	sep3 = Menuseparator;
361
362	Join_item = class
363		Menuaction "_Join" "join two lists end to end" {
364		action a b = a ++ b;
365	}
366
367	Cons_item = class
368		Menuaction "C_ons" "put element a on the front of list x" {
369		action a x = a : x;
370	}
371
372	Zip_item = class
373		Menuaction "_Zip" "join two lists, pairwise" {
374		action a b = zip2 a b;
375	}
376}
377
378Math_round_item = class
379	Menupullright "_Round" "various rounding operations" {
380	/* smallest integral value not less than x
381	 */
382	Ceil_item = class
383		Menuaction "_Ceil" "smallest integral value not less than x" {
384		action x = map_unary ceil x;
385	}
386
387	Floor_item = class
388		Menuaction "_Floor"
389			"largest integral value not greater than x" {
390		action x = map_unary floor x;
391	}
392
393	Rint_item = class
394		Menuaction "_Round to Nearest" "round to nearest integer" {
395		action x = map_unary rint x;
396	}
397}
398
399Math_fourier_item = class
400	Menupullright "_Fourier" "Fourier transform" {
401	Forward_item = class
402		Menuaction "_Forward" "fourier transform of image" {
403		action a = map_unary (rotquad @ fwfft) a;
404	}
405
406	Reverse_item = class
407		Menuaction "_Reverse" "inverse fourier transform of image" {
408		action a = map_unary (invfft @ rotquad) a;
409	}
410
411	Rotate_quadrants_item = class
412		Menuaction "Rotate _Quadrants" "rotate quadrants" {
413		action a = map_unary rotquad a;
414	}
415}
416
417Math_stats_item = class
418	Menupullright "_Statistics" "measure various statistics of objects" {
419	Mean_item = class
420		Menuaction "_Mean" "mean value" {
421		action a = map_unary mean a;
422	}
423
424	Deviation_item = class
425		Menuaction "_Standard Deviation" "standard deviation of object" {
426		action a = map_unary deviation a;
427	}
428
429	Stats_item = class
430		Menuaction "_Many Stats" "calculate many stats in a single pass" {
431		action a = map_unary stats a;
432	}
433
434	sep1 = Menuseparator;
435
436	Max_item = class
437		Menuaction "M_aximum" "maximum of object" {
438		action a = map_unary max a;
439	}
440
441	Min_item = class
442		Menuaction "M_inimum" "minimum of object" {
443		action a = map_unary min a;
444	}
445
446	Maxpos_item = class
447		Menuaction "Position of M_aximum" "position of maximum in object" {
448		action a = map_unary maxpos a;
449	}
450
451	Minpos_item = class
452		Menuaction "Position of M_inimum" "position of minimum in object" {
453		action a = map_unary minpos a;
454	}
455
456	sep2 = Menuseparator;
457
458	Count_set_item = class
459		Menuaction "_Non-zeros" "number of non-zero elements in object" {
460		action a
461			= map_unary cset a
462		{
463			cset i = (mean (i != 0) * i.width * i.height) / 255;
464		}
465	}
466
467	Count_clear_item = class
468		Menuaction "_Zeros" "number of zero elements in object" {
469		action a
470			= map_unary cclear a
471		{
472			cclear i = (mean (i == 0) * i.width * i.height) / 255;
473		}
474	}
475
476	Count_edges_item = class
477		Menuaction "_Edges"
478			"count average edges across or down image" {
479		action x = class
480			_result {
481			_vislevel = 3;
482
483			edge = Option "Count" [
484				"Horizontal lines",
485				"Vertical lines"
486			] 0;
487
488			_result
489				= map_unary process x
490			{
491				process image = Number (edge.labels?edge)
492					(im_cntlines image.value edge.value);
493			}
494		}
495	}
496}
497
498Math_base_item = class
499	Menupullright "Bas_e" "convert number bases" {
500	Hexadecimal_item = class
501		Menuaction "_Hexadecimal" "convert to hexadecimal (base 16)" {
502		action a = map_unary (print_base 16) a;
503	}
504
505	Binary_item = class
506		Menuaction "_Binary" "convert to binary (base 2)" {
507		action a = map_unary (print_base 2) a;
508	}
509
510	Octal_item = class
511		Menuaction "_Octal" "convert to octal (base 8)" {
512		action a = map_unary (print_base 8) a;
513	}
514}
515