1 /* 2 This file is part of GNU APL, a free implementation of the 3 ISO/IEC Standard 13751, "Programming Language APL, Extended" 4 5 Copyright (C) 2008-2015 Dr. Jürgen Sauermann 6 7 This program is free software: you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation, either version 3 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef __SCALAR_FUNCTION_HH_DEFINED__ 22 #define __SCALAR_FUNCTION_HH_DEFINED__ 23 24 #include "Id.hh" 25 #include "Parallel.hh" 26 #include "PrimitiveFunction.hh" 27 #include "Thread_context.hh" 28 29 #include "Value.hh" 30 31 //----------------------------------------------------------------------------- 32 /** Base class for scalar functions (functions whose monadic and/or dyadic 33 version are scalar. 34 */ 35 /// Base class for all scalar functions 36 class ScalarFunction : public PrimitiveFunction 37 { 38 public: 39 /// Construct a ScalarFunction with \b Id \b id ScalarFunction(TokenTag tag,CellFunctionStatistics * stat_AB,CellFunctionStatistics * stat_B,ShapeItem thresh_AB,ShapeItem thresh_B)40 ScalarFunction(TokenTag tag, CellFunctionStatistics * stat_AB, 41 CellFunctionStatistics * stat_B, 42 ShapeItem thresh_AB, 43 ShapeItem thresh_B) 44 : PrimitiveFunction(tag, stat_AB, stat_B) 45 { 46 set_dyadic_threshold(thresh_AB); 47 set_monadic_threshold(thresh_B); 48 } 49 50 /// Evaluate a scalar function monadically. 51 Token eval_scalar_B(Value_P B, prim_f1 fun); 52 53 /// Evaluate a scalar function dyadically. 54 Token eval_scalar_AB(Value_P A, Value_P B, prim_f2 fun); 55 56 /// overloaded Function::get_scalar_f2 57 virtual prim_f2 get_scalar_f2() const = 0; 58 59 /// Evaluate a scalar function dyadically with axis. 60 Token eval_scalar_AXB(Value_P A, Value_P X, Value_P B, prim_f2 fun); 61 62 /// overloaded Function::eval_fill_AB() 63 virtual Token eval_fill_AB(Value_P A, Value_P B); 64 65 /// overloaded Function::eval_fill_B() 66 virtual Token eval_fill_B(Value_P B); 67 68 /// overloaded Function::has_result() has_result() const69 virtual bool has_result() const { return true; } 70 71 protected: 72 /// compute the monadic scalar function \b fun along one ravel 73 Value_P do_scalar_B(ErrorCode & ec, Value_P B, prim_f1 fun); 74 75 /// compute the dyadic scalar function \b fun along one ravel 76 Value_P do_scalar_AB(ErrorCode & ec, Value_P A, Value_P B, prim_f2 fun); 77 78 /// Apply a function to a nested sub array. 79 void expand_pointers(Cell * cell_Z, Value & Z_owner, const Cell * cell_A, 80 const Cell * cell_B, prim_f2 fun); 81 82 /// A helper function for eval_scalar_AXB(). 83 Value_P eval_scalar_AXB(Value_P A, bool * axis_present, 84 Value_P B, prim_f2 fun, bool reversed); 85 86 /// Evaluate \b the identity function. 87 Token eval_scalar_identity_fun(Value_P B, Axis axis, Value_P FI0); 88 89 /// parallel eval_scalar_AB 90 static Thread_context::PoolFunction PF_scalar_AB; 91 92 /// parallel eval_scalar_B 93 static Thread_context::PoolFunction PF_scalar_B; 94 }; 95 96 #define PERF_A(x) TOK_F2_ ## x, \ 97 & Performance::cfs_F2_ ## x ## _AB, 0, \ 98 Performance::thresh_F2_ ## x ## _AB, -1 99 100 #define PERF_AB(x) TOK_F12_ ## x, \ 101 & Performance::cfs_F12_ ## x ## _AB, \ 102 & Performance::cfs_F12_ ## x ## _B, \ 103 Performance::thresh_F12_ ## x ## _AB, \ 104 Performance::thresh_F12_ ## x ## _B 105 106 #define PERF_B(x) TOK_F12_ ## x, \ 107 0, & Performance::cfs_F12_ ## x ## _B, \ 108 -1, Performance::thresh_F12_ ## x ## _B 109 110 //----------------------------------------------------------------------------- 111 /** Scalar functions binomial and factorial. 112 */ 113 /// The class implementing ! 114 class Bif_F12_BINOM : public ScalarFunction 115 { 116 public: 117 /// Constructor. Bif_F12_BINOM()118 Bif_F12_BINOM() 119 : ScalarFunction(PERF_AB(BINOM)) 120 {} 121 122 static Bif_F12_BINOM * fun; ///< Built-in function. 123 static Bif_F12_BINOM _fun; ///< Built-in function. 124 125 protected: 126 /// overloaded Function::eval_B(). eval_B(Value_P B)127 virtual Token eval_B(Value_P B) 128 { return eval_scalar_B(B, &Cell::bif_factorial); } 129 130 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)131 virtual Token eval_AB(Value_P A, Value_P B) 132 { return eval_scalar_AB(A, B, &Cell::bif_binomial); } 133 134 /// overloaded Function::get_scalar_f2 get_scalar_f2() const135 virtual prim_f2 get_scalar_f2() const 136 { return &Cell::bif_binomial; } 137 138 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)139 virtual Token eval_identity_fun(Value_P B, Axis axis) 140 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 141 142 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)143 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 144 { return eval_scalar_AXB(A, X, B, &Cell::bif_binomial); } 145 }; 146 //----------------------------------------------------------------------------- 147 /** Scalar function less than. 148 */ 149 /// The class implementing < 150 class Bif_F2_LESS : public ScalarFunction 151 { 152 public: 153 /// Constructor. Bif_F2_LESS()154 Bif_F2_LESS() 155 : ScalarFunction(PERF_A(LESS)) 156 {} 157 158 static Bif_F2_LESS * fun; ///< Built-in function. 159 static Bif_F2_LESS _fun; ///< Built-in function. 160 161 protected: 162 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)163 virtual Token eval_AB(Value_P A, Value_P B) 164 { return eval_scalar_AB(A, B, &Cell::bif_less_than); } 165 166 /// overloaded Function::get_scalar_f2 get_scalar_f2() const167 virtual prim_f2 get_scalar_f2() const 168 { return &Cell::bif_less_than; } 169 170 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)171 virtual Token eval_identity_fun(Value_P B, Axis axis) 172 { return eval_scalar_identity_fun(B, axis, IntScalar(0, LOC)); } 173 174 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)175 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 176 { return eval_scalar_AXB(A, X, B, &Cell::bif_less_than); } 177 }; 178 //----------------------------------------------------------------------------- 179 /** Scalar function equal. 180 */ 181 /// The class implementing = 182 class Bif_F2_EQUAL : public ScalarFunction 183 { 184 public: 185 /// Constructor. Bif_F2_EQUAL()186 Bif_F2_EQUAL() 187 : ScalarFunction(PERF_A(EQUAL)) 188 {} 189 190 static Bif_F2_EQUAL * fun; ///< Built-in function. 191 static Bif_F2_EQUAL _fun; ///< Built-in function. 192 193 protected: 194 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)195 virtual Token eval_AB(Value_P A, Value_P B) 196 { return eval_scalar_AB(A, B, &Cell::bif_equal); } 197 198 /// overloaded Function::get_scalar_f2 get_scalar_f2() const199 virtual prim_f2 get_scalar_f2() const 200 { return &Cell::bif_equal; } 201 202 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)203 virtual Token eval_identity_fun(Value_P B, Axis axis) 204 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 205 206 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)207 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 208 { return eval_scalar_AXB(A, X, B, &Cell::bif_equal); } 209 }; 210 //----------------------------------------------------------------------------- 211 /** Scalar function EQ bitwise (i.e. bitwise not A xor B) 212 */ 213 /// The class implementing ⊤= 214 class Bif_F2_EQUAL_B : public ScalarFunction 215 { 216 public: 217 /// Constructor. Bif_F2_EQUAL_B()218 Bif_F2_EQUAL_B() 219 : ScalarFunction(PERF_A(EQUAL_B)) 220 {} 221 222 static Bif_F2_EQUAL_B * fun; ///< Built-in function. 223 static Bif_F2_EQUAL_B _fun; ///< Built-in function. 224 225 protected: 226 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)227 virtual Token eval_AB(Value_P A, Value_P B) 228 { return eval_scalar_AB(A, B, &Cell::bif_equal_bitwise); } 229 230 /// overloaded Function::get_scalar_f2 get_scalar_f2() const231 virtual prim_f2 get_scalar_f2() const 232 { return &Cell::bif_equal_bitwise; } 233 234 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)235 virtual Token eval_identity_fun(Value_P B, Axis axis) 236 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 237 238 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)239 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 240 { return eval_scalar_AXB(A, X, B, &Cell::bif_equal_bitwise); } 241 }; 242 //----------------------------------------------------------------------------- 243 /** Scalar function NE bitwise (i.e. bitwise A xor B) 244 */ 245 /// The class implementing ⊤≠ 246 class Bif_F2_UNEQ_B : public ScalarFunction 247 { 248 public: 249 /// Constructor. Bif_F2_UNEQ_B()250 Bif_F2_UNEQ_B() 251 : ScalarFunction(PERF_A(UNEQ_B)) 252 {} 253 254 static Bif_F2_UNEQ_B * fun; ///< Built-in function. 255 static Bif_F2_UNEQ_B _fun; ///< Built-in function. 256 257 protected: 258 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)259 virtual Token eval_AB(Value_P A, Value_P B) 260 { return eval_scalar_AB(A, B, &Cell::bif_not_equal_bitwise); } 261 262 /// overloaded Function::get_scalar_f2 get_scalar_f2() const263 virtual prim_f2 get_scalar_f2() const 264 { return &Cell::bif_not_equal_bitwise; } 265 266 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)267 virtual Token eval_identity_fun(Value_P B, Axis axis) 268 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 269 270 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)271 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 272 { return eval_scalar_AXB(A, X, B, &Cell::bif_not_equal_bitwise); } 273 }; 274 //----------------------------------------------------------------------------- 275 /** Scalar function greater than. 276 */ 277 /// The class implementing > 278 class Bif_F2_GREATER : public ScalarFunction 279 { 280 public: 281 /// Constructor. Bif_F2_GREATER()282 Bif_F2_GREATER() 283 : ScalarFunction(PERF_A(GREATER)) 284 {} 285 286 static Bif_F2_GREATER * fun; ///< Built-in function. 287 static Bif_F2_GREATER _fun; ///< Built-in function. 288 289 protected: 290 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)291 virtual Token eval_AB(Value_P A, Value_P B) 292 { return eval_scalar_AB(A, B, &Cell::bif_greater_than); } 293 294 /// overloaded Function::get_scalar_f2 get_scalar_f2() const295 virtual prim_f2 get_scalar_f2() const 296 { return &Cell::bif_greater_than; } 297 298 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)299 virtual Token eval_identity_fun(Value_P B, Axis axis) 300 { return eval_scalar_identity_fun(B, axis, IntScalar(0, LOC)); } 301 302 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)303 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 304 { return eval_scalar_AXB(A, X, B, &Cell::bif_greater_than); } 305 }; 306 //----------------------------------------------------------------------------- 307 /** Scalar function AND/LCM 308 */ 309 /// The class implementing ∧ 310 class Bif_F2_AND : public ScalarFunction 311 { 312 public: 313 /// Constructor. Bif_F2_AND()314 Bif_F2_AND() 315 : ScalarFunction(PERF_A(AND)) 316 {} 317 318 static Bif_F2_AND * fun; ///< Built-in function. 319 static Bif_F2_AND _fun; ///< Built-in function. 320 321 protected: 322 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)323 virtual Token eval_AB(Value_P A, Value_P B) 324 { return eval_scalar_AB(A, B, &Cell::bif_and); } 325 326 /// overloaded Function::get_scalar_f2 get_scalar_f2() const327 virtual prim_f2 get_scalar_f2() const 328 { return &Cell::bif_and; } 329 330 /// return the associative cell function of this function get_assoc() const331 virtual assoc_f2 get_assoc() const { return &Cell::bif_and; } 332 333 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)334 virtual Token eval_identity_fun(Value_P B, Axis axis) 335 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 336 337 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)338 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 339 { return eval_scalar_AXB(A, X, B, &Cell::bif_and); } 340 }; 341 //----------------------------------------------------------------------------- 342 /** Scalar function AND bitwise 343 */ 344 /// The class implementing ⊤∧ 345 class Bif_F2_AND_B : public ScalarFunction 346 { 347 public: 348 /// Constructor. Bif_F2_AND_B()349 Bif_F2_AND_B() 350 : ScalarFunction(PERF_A(AND_B)) 351 {} 352 353 static Bif_F2_AND_B * fun; ///< Built-in function. 354 static Bif_F2_AND_B _fun; ///< Built-in function. 355 356 protected: 357 /// overloaded Function::eval_B(). eval_B(Value_P B)358 virtual Token eval_B(Value_P B) 359 { return eval_scalar_B(B, &Cell::bif_within_quad_CT); } 360 361 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)362 virtual Token eval_AB(Value_P A, Value_P B) 363 { return eval_scalar_AB(A, B, &Cell::bif_and_bitwise); } 364 365 /// overloaded Function::get_scalar_f2 get_scalar_f2() const366 virtual prim_f2 get_scalar_f2() const 367 { return &Cell::bif_and_bitwise; } 368 369 /// return the associative cell function of this function get_assoc() const370 virtual assoc_f2 get_assoc() const { return &Cell::bif_and_bitwise; } 371 372 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)373 virtual Token eval_identity_fun(Value_P B, Axis axis) 374 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 375 376 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)377 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 378 { return eval_scalar_AXB(A, X, B, &Cell::bif_and_bitwise); } 379 }; 380 //----------------------------------------------------------------------------- 381 /** Scalar function OR/GCD 382 */ 383 /// The class implementing ∨ 384 class Bif_F2_OR : public ScalarFunction 385 { 386 public: 387 /// Constructor. Bif_F2_OR()388 Bif_F2_OR() 389 : ScalarFunction(PERF_A(OR)) 390 {} 391 392 static Bif_F2_OR * fun; ///< Built-in function. 393 static Bif_F2_OR _fun; ///< Built-in function. 394 395 protected: 396 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)397 virtual Token eval_AB(Value_P A, Value_P B) 398 { return eval_scalar_AB(A, B, &Cell::bif_or); } 399 400 /// overloaded Function::get_scalar_f2 get_scalar_f2() const401 virtual prim_f2 get_scalar_f2() const 402 { return &Cell::bif_or; } 403 404 /// return the associative cell function of this function get_assoc() const405 virtual assoc_f2 get_assoc() const { return &Cell::bif_or; } 406 407 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)408 virtual Token eval_identity_fun(Value_P B, Axis axis) 409 { return eval_scalar_identity_fun(B, axis, IntScalar(0, LOC)); } 410 411 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)412 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 413 { return eval_scalar_AXB(A, X, B, &Cell::bif_or); } 414 }; 415 //----------------------------------------------------------------------------- 416 /** Scalar function OR bitwise 417 */ 418 /// The class implementing ⊤∨ 419 class Bif_F2_OR_B : public ScalarFunction 420 { 421 public: 422 /// Constructor. Bif_F2_OR_B()423 Bif_F2_OR_B() 424 : ScalarFunction(PERF_A(OR_B)) 425 {} 426 427 static Bif_F2_OR_B * fun; ///< Built-in function. 428 static Bif_F2_OR_B _fun; ///< Built-in function. 429 430 protected: 431 /// overloaded Function::eval_B(). eval_B(Value_P B)432 virtual Token eval_B(Value_P B) 433 { return eval_scalar_B(B, &Cell::bif_near_int64_t); } 434 435 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)436 virtual Token eval_AB(Value_P A, Value_P B) 437 { return eval_scalar_AB(A, B, &Cell::bif_or_bitwise); } 438 439 /// overloaded Function::get_scalar_f2 get_scalar_f2() const440 virtual prim_f2 get_scalar_f2() const 441 { return &Cell::bif_or_bitwise; } 442 443 /// return the associative cell function of this function get_assoc() const444 virtual assoc_f2 get_assoc() const { return &Cell::bif_or_bitwise; } 445 446 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)447 virtual Token eval_identity_fun(Value_P B, Axis axis) 448 { return eval_scalar_identity_fun(B, axis, IntScalar(0, LOC)); } 449 450 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)451 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 452 { return eval_scalar_AXB(A, X, B, &Cell::bif_or_bitwise); } 453 }; 454 //----------------------------------------------------------------------------- 455 /** Scalar function less or equal. 456 */ 457 /// The class implementing ≤ 458 class Bif_F2_LEQ : public ScalarFunction 459 { 460 public: 461 /// Constructor. Bif_F2_LEQ()462 Bif_F2_LEQ() 463 : ScalarFunction(PERF_A(LEQ)) 464 {} 465 466 static Bif_F2_LEQ * fun; ///< Built-in function. 467 static Bif_F2_LEQ _fun; ///< Built-in function. 468 469 protected: 470 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)471 virtual Token eval_AB(Value_P A, Value_P B) 472 { return eval_scalar_AB(A, B, &Cell::bif_less_eq); } 473 474 /// overloaded Function::get_scalar_f2() get_scalar_f2() const475 virtual prim_f2 get_scalar_f2() const 476 { return &Cell::bif_less_eq; } 477 478 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)479 virtual Token eval_identity_fun(Value_P B, Axis axis) 480 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 481 482 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)483 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 484 { return eval_scalar_AXB(A, X, B, &Cell::bif_less_eq); } 485 }; 486 //----------------------------------------------------------------------------- 487 /** Scalar function greater or equal. 488 */ 489 /// The class implementing ≥ 490 class Bif_F2_MEQ : public ScalarFunction 491 { 492 public: 493 /// Constructor. Bif_F2_MEQ()494 Bif_F2_MEQ() 495 : ScalarFunction(PERF_A(MEQ)) 496 {} 497 498 static Bif_F2_MEQ * fun; ///< Built-in function. 499 static Bif_F2_MEQ _fun; ///< Built-in function. 500 501 protected: 502 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)503 virtual Token eval_AB(Value_P A, Value_P B) 504 { return eval_scalar_AB(A, B, &Cell::bif_greater_eq); } 505 506 /// overloaded Function::get_scalar_f2() get_scalar_f2() const507 virtual prim_f2 get_scalar_f2() const 508 { return &Cell::bif_greater_eq; } 509 510 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)511 virtual Token eval_identity_fun(Value_P B, Axis axis) 512 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 513 514 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)515 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 516 { return eval_scalar_AXB(A, X, B, &Cell::bif_greater_eq); } 517 }; 518 //----------------------------------------------------------------------------- 519 /** Scalar function not equal 520 */ 521 /// The class implementing ≠ 522 class Bif_F2_UNEQ : public ScalarFunction 523 { 524 public: 525 /// Constructor. Bif_F2_UNEQ()526 Bif_F2_UNEQ() 527 : ScalarFunction(PERF_A(UNEQ)) 528 {} 529 530 static Bif_F2_UNEQ * fun; ///< Built-in function. 531 static Bif_F2_UNEQ _fun; ///< Built-in function. 532 533 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)534 virtual Token eval_AB(Value_P A, Value_P B) 535 { return eval_scalar_AB(A, B, &Cell::bif_not_equal); } 536 537 /// overloaded Function::get_scalar_f2() get_scalar_f2() const538 virtual prim_f2 get_scalar_f2() const 539 { return &Cell::bif_not_equal; } 540 541 protected: 542 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)543 virtual Token eval_identity_fun(Value_P B, Axis axis) 544 { return eval_scalar_identity_fun(B, axis, IntScalar(0, LOC)); } 545 546 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)547 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 548 { return eval_scalar_AXB(A, X, B, &Cell::bif_not_equal); } 549 }; 550 //----------------------------------------------------------------------------- 551 /** Scalar function find. 552 */ 553 /// The class implementing ⋸ 554 class Bif_F2_FIND : public ScalarFunction 555 { 556 public: 557 /// Constructor. Bif_F2_FIND()558 Bif_F2_FIND() 559 : ScalarFunction(PERF_A(FIND)) 560 {} 561 562 static Bif_F2_FIND * fun; ///< Built-in function. 563 static Bif_F2_FIND _fun; ///< Built-in function. 564 565 protected: 566 /// overloaded Function::eval_AB(). 567 virtual Token eval_AB(Value_P A, Value_P B); 568 569 /// overloaded Function::get_scalar_f2() get_scalar_f2() const570 virtual prim_f2 get_scalar_f2() const 571 { return 0; } 572 573 /// Return true iff A is contained in B. 574 static bool contained(const Shape & shape_A, const Cell * cA, 575 Value_P B, const Shape & idx_B, double qct); 576 }; 577 //----------------------------------------------------------------------------- 578 /** Scalar function NOR 579 */ 580 /// The class implementing ⍱ 581 class Bif_F2_NOR : public ScalarFunction 582 { 583 public: 584 /// Constructor. Bif_F2_NOR()585 Bif_F2_NOR() 586 : ScalarFunction(PERF_A(NOR)) 587 {} 588 589 static Bif_F2_NOR * fun; ///< Built-in function. 590 static Bif_F2_NOR _fun; ///< Built-in function. 591 592 protected: 593 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)594 virtual Token eval_AB(Value_P A, Value_P B) 595 { return eval_scalar_AB(A, B, &Cell::bif_nor); } 596 597 /// overloaded Function::get_scalar_f2() get_scalar_f2() const598 virtual prim_f2 get_scalar_f2() const 599 { return &Cell::bif_nor; } 600 601 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)602 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 603 { return eval_scalar_AXB(A, X, B, &Cell::bif_nor); } 604 }; 605 //----------------------------------------------------------------------------- 606 /** Scalar function NOR bitwise 607 */ 608 /// The class implementing ⊤⍱ 609 class Bif_F2_NOR_B : public ScalarFunction 610 { 611 public: 612 /// Constructor. Bif_F2_NOR_B()613 Bif_F2_NOR_B() 614 : ScalarFunction(PERF_A(NOR_B)) 615 {} 616 617 static Bif_F2_NOR_B * fun; ///< Built-in function. 618 static Bif_F2_NOR_B _fun; ///< Built-in function. 619 620 protected: 621 /// overloaded Function::eval_B(). eval_B(Value_P B)622 virtual Token eval_B(Value_P B) 623 { return eval_scalar_B(B, &Cell::bif_not_bitwise); } 624 625 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)626 virtual Token eval_AB(Value_P A, Value_P B) 627 { return eval_scalar_AB(A, B, &Cell::bif_nor_bitwise); } 628 629 /// overloaded Function::get_scalar_f2() get_scalar_f2() const630 virtual prim_f2 get_scalar_f2() const 631 { return &Cell::bif_nor_bitwise; } 632 633 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)634 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 635 { return eval_scalar_AXB(A, X, B, &Cell::bif_nor_bitwise); } 636 }; 637 //----------------------------------------------------------------------------- 638 /** Scalar function nand. 639 */ 640 /// The class implementing ⍲ 641 class Bif_F2_NAND : public ScalarFunction 642 { 643 public: 644 /// Constructor. Bif_F2_NAND()645 Bif_F2_NAND() 646 : ScalarFunction(PERF_A(NAND)) 647 {} 648 649 static Bif_F2_NAND * fun; ///< Built-in function. 650 static Bif_F2_NAND _fun; ///< Built-in function. 651 652 protected: 653 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)654 virtual Token eval_AB(Value_P A, Value_P B) 655 { return eval_scalar_AB(A, B, &Cell::bif_nand); } 656 657 /// overloaded Function::get_scalar_f2() get_scalar_f2() const658 virtual prim_f2 get_scalar_f2() const 659 { return &Cell::bif_nand; } 660 661 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)662 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 663 { return eval_scalar_AXB(A, X, B, &Cell::bif_nand); } 664 }; 665 //----------------------------------------------------------------------------- 666 /** Scalar function NAND bitwise 667 */ 668 /// The class implementing ⊤⍲ 669 class Bif_F2_NAND_B : public ScalarFunction 670 { 671 public: 672 /// Constructor. Bif_F2_NAND_B()673 Bif_F2_NAND_B() 674 : ScalarFunction(PERF_A(NAND_B)) 675 {} 676 677 static Bif_F2_NAND_B * fun; ///< Built-in function. 678 static Bif_F2_NAND_B _fun; ///< Built-in function. 679 680 protected: 681 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)682 virtual Token eval_AB(Value_P A, Value_P B) 683 { return eval_scalar_AB(A, B, &Cell::bif_nand_bitwise); } 684 685 /// overloaded Function::get_scalar_f2() get_scalar_f2() const686 virtual prim_f2 get_scalar_f2() const 687 { return &Cell::bif_nand_bitwise; } 688 689 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)690 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 691 { return eval_scalar_AXB(A, X, B, &Cell::bif_nand_bitwise); } 692 }; 693 //----------------------------------------------------------------------------- 694 /** Scalar functions power and exponential. 695 */ 696 /// The class implementing ⋆ 697 class Bif_F12_POWER : public ScalarFunction 698 { 699 public: 700 /// Constructor. Bif_F12_POWER()701 Bif_F12_POWER() 702 : ScalarFunction(PERF_AB(POWER)) 703 {} 704 705 static Bif_F12_POWER * fun; ///< Built-in function. 706 static Bif_F12_POWER _fun; ///< Built-in function. 707 708 protected: 709 /// overloaded Function::eval_B(). eval_B(Value_P B)710 virtual Token eval_B(Value_P B) 711 { return eval_scalar_B(B, &Cell::bif_exponential); } 712 713 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)714 virtual Token eval_AB(Value_P A, Value_P B) 715 { return eval_scalar_AB(A, B, &Cell::bif_power); } 716 717 /// overloaded Function::get_scalar_f2() get_scalar_f2() const718 virtual prim_f2 get_scalar_f2() const 719 { return &Cell::bif_power; } 720 721 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)722 virtual Token eval_identity_fun(Value_P B, Axis axis) 723 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 724 725 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)726 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 727 { return eval_scalar_AXB(A, X, B, &Cell::bif_power); } 728 729 /// overloaded Function::get_monadic_inverse() 730 virtual Function * get_monadic_inverse() const; 731 732 /// overloaded Function::get_dyadic_inverse() 733 virtual Function * get_dyadic_inverse() const; 734 }; 735 //----------------------------------------------------------------------------- 736 /** Scalar functions add and conjugate. 737 */ 738 /// The class implementing + 739 class Bif_F12_PLUS : public ScalarFunction 740 { 741 public: 742 /// Constructor. Bif_F12_PLUS(bool inv)743 Bif_F12_PLUS(bool inv) 744 : ScalarFunction(PERF_AB(PLUS)), 745 inverse(inv) 746 {} 747 748 /// overloaded Function::eval_B(). eval_B(Value_P B)749 virtual Token eval_B(Value_P B) 750 { return eval_scalar_B(B, &Cell::bif_conjugate); } 751 752 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)753 virtual Token eval_AB(Value_P A, Value_P B) 754 { return inverse ? eval_scalar_AB(A, B, &Cell::bif_add_inverse) 755 : eval_scalar_AB(A, B, &Cell::bif_add); } 756 757 /// overloaded Function::get_scalar_f2() get_scalar_f2() const758 virtual prim_f2 get_scalar_f2() const 759 { return inverse ? &Cell::bif_add_inverse : &Cell::bif_add; } 760 761 /// return the associative cell function of this function get_assoc() const762 virtual assoc_f2 get_assoc() const { return &Cell::bif_add; } 763 764 static Bif_F12_PLUS * fun; ///< Built-in function. 765 static Bif_F12_PLUS _fun; ///< Built-in function. 766 static Bif_F12_PLUS * fun_inverse; ///< Built-in function. 767 static Bif_F12_PLUS _fun_inverse; ///< Built-in function. 768 769 protected: 770 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)771 virtual Token eval_identity_fun(Value_P B, Axis axis) 772 { return eval_scalar_identity_fun(B, axis, IntScalar(0, LOC)); } 773 774 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)775 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 776 { return eval_scalar_AXB(A, X, B, &Cell::bif_add); } 777 778 /// overloaded Function::get_dyadic_inverse() 779 virtual Function * get_dyadic_inverse() const; 780 781 /// true if the inverse shall be computed. This allows Bif_F12_CIRCLE to 782 /// be instantiated twice: once for non-inverted operation and once for 783 /// inverted operation, and both instances can share some code in this class 784 const bool inverse; 785 }; 786 //----------------------------------------------------------------------------- 787 /** Scalar functions subtract and negative. 788 */ 789 /// The class implementing - 790 class Bif_F12_MINUS : public ScalarFunction 791 { 792 public: 793 /// Constructor. Bif_F12_MINUS()794 Bif_F12_MINUS() 795 : ScalarFunction(PERF_AB(MINUS)) 796 {} 797 798 static Bif_F12_MINUS * fun; ///< Built-in function. 799 static Bif_F12_MINUS _fun; ///< Built-in function. 800 801 protected: 802 /// overloaded Function::eval_B(). eval_B(Value_P B)803 virtual Token eval_B(Value_P B) 804 { return eval_scalar_B(B, &Cell::bif_negative); } 805 806 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)807 virtual Token eval_AB(Value_P A, Value_P B) 808 { return eval_scalar_AB(A, B, &Cell::bif_subtract); } 809 810 /// overloaded Function::get_scalar_f2() get_scalar_f2() const811 virtual prim_f2 get_scalar_f2() const 812 { return &Cell::bif_subtract; } 813 814 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)815 virtual Token eval_identity_fun(Value_P B, Axis axis) 816 { return eval_scalar_identity_fun(B, axis, IntScalar(0, LOC)); } 817 818 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)819 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 820 { return eval_scalar_AXB(A, X, B, &Cell::bif_subtract); } 821 822 /// overloaded Function::get_monadic_inverse() 823 virtual Function * get_monadic_inverse() const; 824 825 /// overloaded Function::get_dyadic_inverse() 826 virtual Function * get_dyadic_inverse() const; 827 }; 828 //----------------------------------------------------------------------------- 829 /** Scalar function roll and non-scalar function dial. 830 */ 831 /// The class implementing ? 832 class Bif_F12_ROLL : public ScalarFunction 833 { 834 public: 835 /// Constructor. Bif_F12_ROLL()836 Bif_F12_ROLL() 837 : ScalarFunction(PERF_B(ROLL)) 838 {} 839 840 static Bif_F12_ROLL * fun; ///< Built-in function. 841 static Bif_F12_ROLL _fun; ///< Built-in function. 842 843 protected: 844 /// overloaded Function::eval_B(). 845 virtual Token eval_B(Value_P B); 846 847 /// dial A from B. 848 /// overloaded Function::eval_AB(). 849 virtual Token eval_AB(Value_P A, Value_P B); 850 851 /// overloaded Function::get_scalar_f2 get_scalar_f2() const852 virtual prim_f2 get_scalar_f2() const 853 { return 0; } 854 855 /// recursively check that all ravel elements of B are integers ≥ 0 and 856 /// return \b true iff not. 857 static bool check_B(const Value & B, double qct); 858 }; 859 //----------------------------------------------------------------------------- 860 /** Scalar function not and non-scalar function without. 861 */ 862 /// The class implementing ∼ 863 class Bif_F12_WITHOUT : public ScalarFunction 864 { 865 public: 866 /// Constructor. Bif_F12_WITHOUT()867 Bif_F12_WITHOUT() 868 : ScalarFunction(PERF_B(WITHOUT)) 869 {} 870 871 static Bif_F12_WITHOUT * fun; ///< Built-in function. 872 static Bif_F12_WITHOUT _fun; ///< Built-in function. 873 874 /// Compute A without B. 875 /// overloaded Function::eval_AB(). 876 virtual Token eval_AB(Value_P A, Value_P B); 877 878 protected: 879 /// overloaded Function::eval_B(). eval_B(Value_P B)880 virtual Token eval_B(Value_P B) 881 { return eval_scalar_B(B, &Cell::bif_not); } 882 883 /// overloaded Function::get_scalar_f2 get_scalar_f2() const884 virtual prim_f2 get_scalar_f2() const 885 { return 0; } 886 887 /// eval_AB for large A and/or B 888 Value_P large_eval_AB(const Value * A, const Value * B); 889 }; 890 //----------------------------------------------------------------------------- 891 /** Scalar functions times and direction. 892 */ 893 /// The class implementing × 894 class Bif_F12_TIMES : public ScalarFunction 895 { 896 public: 897 /// Constructor. Bif_F12_TIMES(bool inv)898 Bif_F12_TIMES(bool inv) 899 : ScalarFunction(PERF_AB(TIMES)), 900 inverse(inv) 901 {} 902 903 static Bif_F12_TIMES * fun; ///< Built-in function. 904 static Bif_F12_TIMES _fun; ///< Built-in function. 905 static Bif_F12_TIMES * fun_inverse; ///< Built-in function. 906 static Bif_F12_TIMES _fun_inverse; ///< Built-in function. 907 908 protected: 909 /// overloaded Function::eval_B(). eval_B(Value_P B)910 virtual Token eval_B(Value_P B) 911 { return eval_scalar_B(B, &Cell::bif_direction); } 912 913 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)914 virtual Token eval_AB(Value_P A, Value_P B) 915 { return inverse ? eval_scalar_AB(A, B, &Cell::bif_multiply_inverse) 916 : eval_scalar_AB(A, B, &Cell::bif_multiply); } 917 918 /// overloaded Function::get_scalar_f2() get_scalar_f2() const919 virtual prim_f2 get_scalar_f2() const 920 { return inverse ? &Cell::bif_multiply_inverse : &Cell::bif_multiply; } 921 922 /// return the associative cell function of this function get_assoc() const923 virtual assoc_f2 get_assoc() const { return &Cell::bif_multiply; } 924 925 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)926 virtual Token eval_identity_fun(Value_P B, Axis axis) 927 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 928 929 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)930 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 931 { return eval_scalar_AXB(A, X, B, &Cell::bif_multiply); } 932 933 /// overloaded Function::get_dyadic_inverse() 934 virtual Function * get_dyadic_inverse() const; 935 936 /// true if the inverse shall be computed. This allows Bif_F12_CIRCLE to 937 /// be instantiated twice: once for non-inverted operation and once for 938 /// inverted operation, and both instances can share some code in this class 939 const bool inverse; 940 }; 941 //----------------------------------------------------------------------------- 942 /** Scalar functions divide and reciprocal. 943 */ 944 /// The class implementing ÷ 945 class Bif_F12_DIVIDE : public ScalarFunction 946 { 947 public: 948 /// Constructor. Bif_F12_DIVIDE()949 Bif_F12_DIVIDE() 950 : ScalarFunction(PERF_AB(DIVIDE)) 951 {} 952 953 static Bif_F12_DIVIDE * fun; ///< Built-in function. 954 static Bif_F12_DIVIDE _fun; ///< Built-in function. 955 956 protected: 957 /// overloaded Function::eval_B(). eval_B(Value_P B)958 virtual Token eval_B(Value_P B) 959 { return eval_scalar_B(B, &Cell::bif_reciprocal); } 960 961 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)962 virtual Token eval_AB(Value_P A, Value_P B) 963 { return eval_scalar_AB(A, B, &Cell::bif_divide); } 964 965 /// overloaded Function::get_scalar_f2 get_scalar_f2() const966 virtual prim_f2 get_scalar_f2() const 967 { return &Cell::bif_divide; } 968 969 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)970 virtual Token eval_identity_fun(Value_P B, Axis axis) 971 { return eval_scalar_identity_fun(B, axis, IntScalar(1, LOC)); } 972 973 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)974 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 975 { return eval_scalar_AXB(A, X, B, &Cell::bif_divide); } 976 977 /// overloaded Function::get_monadic_inverse() 978 virtual Function * get_monadic_inverse() const; 979 980 /// overloaded Function::get_dyadic_inverse() 981 virtual Function * get_dyadic_inverse() const; 982 }; 983 //----------------------------------------------------------------------------- 984 /** Scalar functions circle functions and pi times. 985 */ 986 /// The class implementing ○ 987 class Bif_F12_CIRCLE : public ScalarFunction 988 { 989 public: 990 /// Constructor. Bif_F12_CIRCLE(bool inv)991 Bif_F12_CIRCLE(bool inv) 992 : ScalarFunction(PERF_AB(CIRCLE)), 993 inverse(inv) 994 {} 995 996 static Bif_F12_CIRCLE * fun; ///< Built-in function. 997 static Bif_F12_CIRCLE _fun; ///< Built-in function. 998 static Bif_F12_CIRCLE * fun_inverse; ///< Built-in function. 999 static Bif_F12_CIRCLE _fun_inverse; ///< Built-in function. 1000 1001 protected: 1002 /// overloaded Function::eval_B(). eval_B(Value_P B)1003 virtual Token eval_B(Value_P B) 1004 { return inverse ? eval_scalar_B(B, &Cell::bif_pi_times_inverse) 1005 : eval_scalar_B(B, &Cell::bif_pi_times); } 1006 1007 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)1008 virtual Token eval_AB(Value_P A, Value_P B) 1009 { return inverse ? eval_scalar_AB(A, B, &Cell::bif_circle_fun_inverse) 1010 : eval_scalar_AB(A, B, &Cell::bif_circle_fun); } 1011 1012 /// overloaded Function::get_scalar_f2 get_scalar_f2() const1013 virtual prim_f2 get_scalar_f2() const 1014 { return inverse ? &Cell::bif_circle_fun_inverse 1015 : &Cell::bif_circle_fun; } 1016 1017 /// overloaded Function::get_monadic_inverse() 1018 virtual Function * get_monadic_inverse() const; 1019 1020 /// overloaded Function::get_dyadic_inverse() 1021 virtual Function * get_dyadic_inverse() const; 1022 1023 /// true if the inverse shall be computed. This allows Bif_F12_CIRCLE to 1024 /// be instantiated twice: once for non-inverted operation and once for 1025 /// inverted operation, and both instances can share some code in this class 1026 const bool inverse; 1027 }; 1028 //----------------------------------------------------------------------------- 1029 /** Scalar functions maximum and round up. 1030 */ 1031 /// The class implementing ⌈ 1032 class Bif_F12_RND_UP : public ScalarFunction 1033 { 1034 public: 1035 /// Constructor. Bif_F12_RND_UP()1036 Bif_F12_RND_UP() 1037 : ScalarFunction(PERF_AB(RND_UP)) 1038 {} 1039 1040 static Bif_F12_RND_UP * fun; ///< Built-in function. 1041 static Bif_F12_RND_UP _fun; ///< Built-in function. 1042 1043 protected: 1044 /// overloaded Function::eval_B(). eval_B(Value_P B)1045 virtual Token eval_B(Value_P B) 1046 { return eval_scalar_B(B, &Cell::bif_ceiling); } 1047 1048 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)1049 virtual Token eval_AB(Value_P A, Value_P B) 1050 { return eval_scalar_AB(A, B, &Cell::bif_maximum); } 1051 1052 /// overloaded Function::get_scalar_f2() get_scalar_f2() const1053 virtual prim_f2 get_scalar_f2() const 1054 { return &Cell::bif_maximum; } 1055 1056 /// return the associative cell function of this function get_assoc() const1057 virtual assoc_f2 get_assoc() const { return &Cell::bif_maximum; } 1058 1059 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)1060 virtual Token eval_identity_fun(Value_P B, Axis axis) 1061 { return eval_scalar_identity_fun(B, axis, FloatScalar(-BIG_FLOAT, LOC)); } 1062 1063 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)1064 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 1065 { return eval_scalar_AXB(A, X, B, &Cell::bif_maximum); } 1066 }; 1067 //----------------------------------------------------------------------------- 1068 /** Scalar functions minimum and round down. 1069 */ 1070 /// The class implementing ⌊ 1071 class Bif_F12_RND_DN : public ScalarFunction 1072 { 1073 public: 1074 /// Constructor. Bif_F12_RND_DN()1075 Bif_F12_RND_DN() 1076 : ScalarFunction(PERF_AB(RND_DN)) 1077 {} 1078 1079 static Bif_F12_RND_DN * fun; ///< Built-in function. 1080 static Bif_F12_RND_DN _fun; ///< Built-in function. 1081 1082 protected: 1083 /// overloaded Function::eval_B(). eval_B(Value_P B)1084 virtual Token eval_B(Value_P B) 1085 { return eval_scalar_B(B, &Cell::bif_floor); } 1086 1087 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)1088 virtual Token eval_AB(Value_P A, Value_P B) 1089 { return eval_scalar_AB(A, B, &Cell::bif_minimum); } 1090 1091 /// overloaded Function::get_scalar_f2() get_scalar_f2() const1092 virtual prim_f2 get_scalar_f2() const 1093 { return &Cell::bif_minimum; } 1094 1095 /// return the associative cell function of this function get_assoc() const1096 virtual assoc_f2 get_assoc() const { return &Cell::bif_minimum; } 1097 1098 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)1099 virtual Token eval_identity_fun(Value_P B, Axis axis) 1100 { return eval_scalar_identity_fun(B, axis, FloatScalar(BIG_FLOAT, LOC)); } 1101 1102 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)1103 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 1104 { return eval_scalar_AXB(A, X, B, &Cell::bif_minimum); } 1105 }; 1106 //----------------------------------------------------------------------------- 1107 /** Scalar functions residue and magnitude. 1108 */ 1109 /// The class implementing ∣ 1110 class Bif_F12_STILE : public ScalarFunction 1111 { 1112 public: 1113 /// Constructor. Bif_F12_STILE()1114 Bif_F12_STILE() 1115 : ScalarFunction(PERF_AB(STILE)) 1116 {} 1117 1118 static Bif_F12_STILE * fun; ///< Built-in function. 1119 static Bif_F12_STILE _fun; ///< Built-in function. 1120 1121 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)1122 virtual Token eval_AB(Value_P A, Value_P B) 1123 { return eval_scalar_AB(A, B, &Cell::bif_residue); } 1124 1125 /// overloaded Function::get_scalar_f2() get_scalar_f2() const1126 virtual prim_f2 get_scalar_f2() const 1127 { return &Cell::bif_residue; } 1128 1129 protected: 1130 /// overloaded Function::eval_B(). eval_B(Value_P B)1131 virtual Token eval_B(Value_P B) 1132 { return eval_scalar_B(B, &Cell::bif_magnitude); } 1133 1134 /// overloaded Function::eval_identity_fun(); eval_identity_fun(Value_P B,Axis axis)1135 virtual Token eval_identity_fun(Value_P B, Axis axis) 1136 { return eval_scalar_identity_fun(B, axis, IntScalar(0, LOC)); } 1137 1138 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)1139 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 1140 { return eval_scalar_AXB(A, X, B, &Cell::bif_residue); } 1141 }; 1142 //----------------------------------------------------------------------------- 1143 /** Scalar functions logarithms. 1144 */ 1145 /// The class implementing ⍟ 1146 class Bif_F12_LOGA : public ScalarFunction 1147 { 1148 public: 1149 /// Constructor. Bif_F12_LOGA()1150 Bif_F12_LOGA() 1151 : ScalarFunction(PERF_AB(LOGA)) 1152 {} 1153 1154 static Bif_F12_LOGA * fun; ///< Built-in function. 1155 static Bif_F12_LOGA _fun; ///< Built-in function. 1156 1157 protected: 1158 /// overloaded Function::eval_B(). eval_B(Value_P B)1159 virtual Token eval_B(Value_P B) 1160 { return eval_scalar_B(B, &Cell::bif_nat_log); } 1161 1162 /// overloaded Function::eval_AB(). eval_AB(Value_P A,Value_P B)1163 virtual Token eval_AB(Value_P A, Value_P B) 1164 { return eval_scalar_AB(A, B, &Cell::bif_logarithm); } 1165 1166 /// overloaded Function::get_scalar_f2() get_scalar_f2() const1167 virtual prim_f2 get_scalar_f2() const 1168 { return &Cell::bif_logarithm; } 1169 1170 /// overloaded Function::eval_AXB(). eval_AXB(Value_P A,Value_P X,Value_P B)1171 virtual Token eval_AXB(Value_P A, Value_P X, Value_P B) 1172 { return eval_scalar_AXB(A, X, B, &Cell::bif_logarithm); } 1173 1174 /// overloaded Function::get_monadic_inverse() 1175 virtual Function * get_monadic_inverse() const; 1176 1177 /// overloaded Function::get_dyadic_inverse() 1178 virtual Function * get_dyadic_inverse() const; 1179 }; 1180 //----------------------------------------------------------------------------- 1181 1182 #endif // __SCALAR_FUNCTION_HH_DEFINED__ 1183