Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
calculate_value [2011/07/26 19:23]
hermann created
calculate_value [2026/08/28 03:14] (current)
hermann Sync from local documentation review
Line 1: Line 1:
-====== Calculate Value ====== ​+====== Calculate Value ======
  
 ===== Description ===== ===== Description =====
  
-This container calculates ​a value employing ​logic/​algebraic ​expression.+Evaluates an algebraic or logical expression once and returns ​single scalar ​value. Unlike the map and lookup table calculators,​ there is no current cell, row, or spatial grid: the expression is evaluated in purely scalar context, drawing only on tables, lookup tables, and scalar values connected through hooks. 
 + 
 +This is one of Dinamica EGO's five calculator functors. Its abbreviated (shorthand) syntax is ''​$''​. See [[ego_script#​calculator_functor_shorthand|Calculator functor shorthand]] in the EGO Script documentation for the verbose and abbreviated forms, and [[Calculate Functors|Calculate Functors — Complete Operator Documentation]] for the full expression ​language reference.
  
 ===== Inputs ===== ===== Inputs =====
  
-^ Name            ^ Type                                              ^ Description ​                              ​+^ Name  ^ Type  ^ Description ​ 
-| Expression ​     | [[Image Expression Type|Image Expression  ​]]      | Algebraic or logical expression ​used to calculate the lookup table. |+| Expression ​ | [[Image Expression Type]] ​ | Algebraic or logical expression ​that evaluates ​to a single numeric resultMust be enclosed in square brackets ''​[ ]''​ in EGO Script.  ​|
  
 ===== Optional Inputs ===== ===== Optional Inputs =====
  
-^ Name              ^ Type                      ^ Description ​                                                                                                                                      ​^ Default Value ^ +^ Name  ^ Type  ^ Description ​ ^ Default Value  
-Use Default Value | [[Bool Type|Bool  ​]]      If true, a default value will be passed as an output of the algebraic/​logic ​expression ​in case an algebraic error occurse.g. division by zero.  | False         | +| Default Value  | [[Real Value Type]] ​ Value returned if evaluating ​the expression ​produces ​an algebraic error. When not providedevaluation errors are propagatedThis is an advanced port.  | .none  |
-| Default Value     | [[Double Type|Double ​ ]]  | Value to be passed in case an algebraic error occurs. ​                                                                                            | 0.0           |+
  
 +===== Outputs =====
  
-===== Output ===== +^ Name  ^ Type  ^ Description ​ 
- +Result  ​| [[Real Value Type]] ​ | The computed scalar ​value. ​ |
-^ Name       ​^ Type                      ^ Description ​          ​+
-Calculated ​| [[Double ​Type|Double  ​]]  | The calculated ​value. |+
  
 ===== Group ===== ===== Group =====
Line 28: Line 28:
 ===== Notes ===== ===== Notes =====
  
-The list of mathematical and logical operators that can be employed in the logic/​algebraic expression can be found in the [[Image Expression Type | image expression reference]]. Note that the operators and functions described in [[Image Expression Type#Image Operators and Functions | Image Operators and Functions]] ​ and [[Image Expression Type#Image Neighborhood Functions +==== Connecting data inputs ====
-| Image Neighborhood Functions]] can not be used in value calculations.+
  
-The tables ​used by the "​Calculate Lookup Table" ​must be provided by a corresponding ​[[Number Table]] ​and the values ​must be provided ​by a corresponding ​[[Number ​Value]].+Tables, lookup ​tables, and scalar values referenced in the expression ​must be connected to the functor'​s ports before writing the expression, using hook functors: 
 + 
 +  * Tables and lookup tables → [[Number Table]] ​→ referenced in the expression as t1, t2, …, t100 
 +  * Scalar ​values ​→ [[Number Value]] → referenced as v1, v2, …, v100 
 + 
 +Maps cannot ​be connected — there is no cell context in this functor. In the abbreviated syntax, tables are referenced as ''​%variableName''​ and values as ''​$variableName''​. 
 + 
 +==== Available expression features ==== 
 + 
 +Image operators (''​iX''​),​ the line and column spatial keywords, neighbourhood functions, neighbourhood indexing, and convolution are not available — there is no cell or row context. Available features are arithmetic and logical operators and table and lookup table queries (''​tX[...]''​) in all single-key and multi-column forms. See [[Calculate Functors#​The Expression Language|The Expression Language]] for the complete reference, or [[Image Expression Type]] for the navigable operator index. 
 + 
 +All operations are performed using the precision defined ​by ImageExpression::​Value;​ the final result is then converted to double-precision real. See [[Calculate ​Value 2]] for a variant that instead performs all operations using double precision throughout. 
 + 
 +==== Null value handling ==== 
 + 
 +Null propagation rules and defensive patterns are covered in [[Calculate Functors#​Null Value Handling|Null Value Handling]] in the Calculate Functors documentation.
  
 ===== Internal Name ===== ===== Internal Name =====
  
 CalculateValue CalculateValue
 +
 +===== Usage examples =====
 +
 +  * [[Calculate Functors#​CalculateValue practical examples|CalculateValue practical examples]] in the Calculate Functors documentation
 +  * [[lesson_8|Lesson 8: Inserting and getting a specific value into a table]]