Test_DataTypeConversion_to_Double Test_DataTypeConversion_to_Double Icon

Test_DataTypeConversion_to_Double

Usage

PrimitiveComponents.Test_DataTypeConversion_to_Double()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( constant_{1_{+}y(t)}, datatypeconversion_{to\_double\_1_{+}u(t)} \right) \\ \mathrm{connect}\left( constant_{2_{+}y(t)}, datatypeconversion_{to\_double\_2_{+}u(t)} \right) \\ \mathrm{connect}\left( constant_{3_{+}y(t)}, datatypeconversion_{to\_double\_3_{+}u(t)} \right) \\ \mathrm{connect}\left( constant_{4_{+}y(t)}, datatypeconversion_{to\_double\_4_{+}u(t)} \right) \\ \mathrm{connect}\left( constant_{5_{+}y(t)}, datatypeconversion_{to\_double\_5_{+}u(t)} \right) \\ \mathtt{datatypeconversion\_to\_double\_1.y}\left( t \right) = to\_double\_floor\left( \mathtt{datatypeconversion\_to\_double\_1.u}\left( t \right), \mathtt{datatypeconversion\_to\_double\_1.saturate\_on\_overflow} \right) \\ \mathtt{constant\_1.y}\left( t \right) = \mathtt{constant\_1.k} \\ \mathtt{datatypeconversion\_to\_double\_2.y}\left( t \right) = to\_double\_floor\left( \mathtt{datatypeconversion\_to\_double\_2.u}\left( t \right), \mathtt{datatypeconversion\_to\_double\_2.saturate\_on\_overflow} \right) \\ \mathtt{constant\_2.y}\left( t \right) = \mathtt{constant\_2.k} \\ \mathtt{datatypeconversion\_to\_double\_3.y}\left( t \right) = to\_double\_floor\left( \mathtt{datatypeconversion\_to\_double\_3.u}\left( t \right), \mathtt{datatypeconversion\_to\_double\_3.saturate\_on\_overflow} \right) \\ \mathtt{constant\_3.y}\left( t \right) = \mathtt{constant\_3.k} \\ \mathtt{datatypeconversion\_to\_double\_4.y}\left( t \right) = to\_double\_floor\left( \mathtt{datatypeconversion\_to\_double\_4.u}\left( t \right), \mathtt{datatypeconversion\_to\_double\_4.saturate\_on\_overflow} \right) \\ \mathtt{constant\_4.y}\left( t \right) = \mathtt{constant\_4.k} \\ \mathtt{datatypeconversion\_to\_double\_5.y}\left( t \right) = to\_double\_floor\left( \mathtt{datatypeconversion\_to\_double\_5.u}\left( t \right), \mathtt{datatypeconversion\_to\_double\_5.saturate\_on\_overflow} \right) \\ \mathtt{constant\_5.y}\left( t \right) = \mathtt{constant\_5.k} \\ \end{array} \right] \end{equation} \]

Source

# This test model validates the DataTypeConversion_to_Double block using five constant inputs with both overflow modes.
#
# The test cases include: 
# 42.7 → 42.0 (overflow=false)
# -3.2 → -4.0 (overflow=false)
# 1e12 → 1.0e12 (overflow=false)
# 0.00001 → 0.0 (overflow=true)
# -0.00001 → -1.0 (overflow=false)
component Test_DataTypeConversion_to_Double
  datatypeconversion_to_double_1 = PrimitiveComponents.WIP.DataTypeConversion_to_Double(saturate_on_overflow = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 680, "y1": 210, "x2": 780, "y2": 310, "rot": 0}
      }
    }
  }
  constant_1 = BlockComponents.Constant(k = 42.7) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 240, "y1": 210, "x2": 340, "y2": 310, "rot": 0}
      }
    }
  }
  datatypeconversion_to_double_2 = PrimitiveComponents.WIP.DataTypeConversion_to_Double(saturate_on_overflow = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 690, "y1": 380, "x2": 790, "y2": 480, "rot": 0}
      }
    }
  }
  constant_2 = BlockComponents.Constant(k = -3.2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 380, "x2": 350, "y2": 480, "rot": 0}
      }
    }
  }
  datatypeconversion_to_double_3 = PrimitiveComponents.WIP.DataTypeConversion_to_Double(saturate_on_overflow = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 700, "y1": 570, "x2": 800, "y2": 670, "rot": 0}
      }
    }
  }
  constant_3 = BlockComponents.Constant(k = 1e12) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 570, "x2": 350, "y2": 670, "rot": 0}
      }
    }
  }
  datatypeconversion_to_double_4 = PrimitiveComponents.WIP.DataTypeConversion_to_Double(saturate_on_overflow = true) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 710, "y1": 750, "x2": 810, "y2": 850, "rot": 0}
      }
    }
  }
  constant_4 = BlockComponents.Constant(k = 0.00001) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 260, "y1": 750, "x2": 360, "y2": 850, "rot": 0}
      }
    }
  }
  datatypeconversion_to_double_5 = PrimitiveComponents.WIP.DataTypeConversion_to_Double(saturate_on_overflow = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 720, "y1": 950, "x2": 820, "y2": 1050, "rot": 0}
      }
    }
  }
  constant_5 = BlockComponents.Constant(k = -0.00001) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 950, "x2": 350, "y2": 1050, "rot": 0}
      }
    }
  }
relations
  connect(constant_1.y, datatypeconversion_to_double_1.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
  connect(constant_2.y, datatypeconversion_to_double_2.u) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(datatypeconversion_to_double_3.u, constant_3.y) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(constant_4.y, datatypeconversion_to_double_4.u) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(constant_5.y, datatypeconversion_to_double_5.u) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {
  "Dyad": {
    "experiments": {"Test_DataTypeConversion_to_Double_": {"stop": 2}},
    "tests": {
      "case1": {
        "stop": 5,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {
          "signals": [
            "datatypeconversion_to_double_1.y",
            "datatypeconversion_to_double_2.y",
            "datatypeconversion_to_double_3.y",
            "datatypeconversion_to_double_4.y",
            "datatypeconversion_to_double_5.y"
          ]
        }
      }
    }
  }
}
end
Flattened Source
component Test_DataTypeConversion_to_Double
  datatypeconversion_to_double_1 = PrimitiveComponents.WIP.DataTypeConversion_to_Double(saturate_on_overflow = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 680, "y1": 210, "x2": 780, "y2": 310, "rot": 0}
      }
    }
  }
  constant_1 = BlockComponents.Constant(k = 42.7) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 240, "y1": 210, "x2": 340, "y2": 310, "rot": 0}
      }
    }
  }
  datatypeconversion_to_double_2 = PrimitiveComponents.WIP.DataTypeConversion_to_Double(saturate_on_overflow = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 690, "y1": 380, "x2": 790, "y2": 480, "rot": 0}
      }
    }
  }
  constant_2 = BlockComponents.Constant(k = -3.2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 380, "x2": 350, "y2": 480, "rot": 0}
      }
    }
  }
  datatypeconversion_to_double_3 = PrimitiveComponents.WIP.DataTypeConversion_to_Double(saturate_on_overflow = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 700, "y1": 570, "x2": 800, "y2": 670, "rot": 0}
      }
    }
  }
  constant_3 = BlockComponents.Constant(k = 1e12) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 570, "x2": 350, "y2": 670, "rot": 0}
      }
    }
  }
  datatypeconversion_to_double_4 = PrimitiveComponents.WIP.DataTypeConversion_to_Double(saturate_on_overflow = true) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 710, "y1": 750, "x2": 810, "y2": 850, "rot": 0}
      }
    }
  }
  constant_4 = BlockComponents.Constant(k = 0.00001) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 260, "y1": 750, "x2": 360, "y2": 850, "rot": 0}
      }
    }
  }
  datatypeconversion_to_double_5 = PrimitiveComponents.WIP.DataTypeConversion_to_Double(saturate_on_overflow = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 720, "y1": 950, "x2": 820, "y2": 1050, "rot": 0}
      }
    }
  }
  constant_5 = BlockComponents.Constant(k = -0.00001) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 950, "x2": 350, "y2": 1050, "rot": 0}
      }
    }
  }
relations
  connect(constant_1.y, datatypeconversion_to_double_1.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
  connect(constant_2.y, datatypeconversion_to_double_2.u) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(datatypeconversion_to_double_3.u, constant_3.y) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(constant_4.y, datatypeconversion_to_double_4.u) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(constant_5.y, datatypeconversion_to_double_5.u) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {
  "Dyad": {
    "experiments": {"Test_DataTypeConversion_to_Double_": {"stop": 2}},
    "tests": {
      "case1": {
        "stop": 5,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {
          "signals": [
            "datatypeconversion_to_double_1.y",
            "datatypeconversion_to_double_2.y",
            "datatypeconversion_to_double_3.y",
            "datatypeconversion_to_double_4.y",
            "datatypeconversion_to_double_5.y"
          ]
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

plt
Example block output
plt
Example block output
plt
Example block output
plt
Example block output
plt
Example block output
  • Examples
  • Experiments
  • Analyses