| 2788 | } |
| 2789 | |
| 2790 | int OPS_transformUtoX() { |
| 2791 | ProbabilityTransformation *theTransf = |
| 2792 | cmds->getProbabilityTransformation(); |
| 2793 | if (theTransf == 0) { |
| 2794 | opserr << "ERROR: probability transformation has not been set" |
| 2795 | << endln; |
| 2796 | return -1; |
| 2797 | } |
| 2798 | |
| 2799 | ReliabilityDomain *theReliabilityDomain = cmds->getDomain(); |
| 2800 | int nrv = theReliabilityDomain->getNumberOfRandomVariables(); |
| 2801 | |
| 2802 | if (OPS_GetNumRemainingInputArgs() < nrv) { |
| 2803 | opserr << "ERROR: transformUtoX insufficient # args" << endln; |
| 2804 | return -1; |
| 2805 | } |
| 2806 | if (OPS_GetNumRemainingInputArgs() > nrv && |
| 2807 | OPS_GetNumRemainingInputArgs() < 2 * nrv) { |
| 2808 | opserr << "ERROR: transformUtoX insufficient # rv tags" << endln; |
| 2809 | return -1; |
| 2810 | } |
| 2811 | |
| 2812 | int numData = 1; |
| 2813 | double val; |
| 2814 | Vector u(nrv); |
| 2815 | int loc = 0; |
| 2816 | // Read in u-values |
| 2817 | while (loc < nrv && OPS_GetNumRemainingInputArgs() > 0) { |
| 2818 | if (OPS_GetDoubleInput(&numData, &val) < 0) { |
| 2819 | OPS_ResetCurrentInputArg(-1); |
| 2820 | break; |
| 2821 | } |
| 2822 | u(loc) = val; |
| 2823 | loc++; |
| 2824 | } |
| 2825 | |
| 2826 | ID rvIndex(nrv); |
| 2827 | // Initialize the index to be sequential (default) |
| 2828 | for (int i = 0; i < nrv; i++) rvIndex(i) = i; |
| 2829 | |
| 2830 | int rvTag; |
| 2831 | loc = 0; |
| 2832 | // Now read in rv tags and get their indices |
| 2833 | while (loc < nrv && OPS_GetNumRemainingInputArgs() > 0) { |
| 2834 | if (OPS_GetIntInput(&numData, &rvTag) < 0) { |
| 2835 | OPS_ResetCurrentInputArg(-1); |
| 2836 | break; |
| 2837 | } |
| 2838 | rvIndex(loc) = theReliabilityDomain->getRandomVariableIndex(rvTag); |
| 2839 | loc++; |
| 2840 | } |
| 2841 | |
| 2842 | // Map in |
| 2843 | Vector uSorted(nrv); |
| 2844 | for (int i = 0; i < nrv; i++) uSorted(rvIndex(i)) = u(i); |
| 2845 | |
| 2846 | Vector x(nrv); |
| 2847 | theTransf->transform_u_to_x(uSorted, x); |
no test coverage detected