Changeset View
Changeset View
Standalone View
Standalone View
analitza/operations.cpp
Show First 20 Lines • Show All 409 Lines • ▼ Show 20 Line(s) | 409 | case Operator::arccos: | |||
---|---|---|---|---|---|
410 | oper->setValue(acos(a)); | 410 | oper->setValue(acos(a)); | ||
411 | break; | 411 | break; | ||
412 | case Operator::arctan: | 412 | case Operator::arctan: | ||
413 | oper->setValue(atan(a)); | 413 | oper->setValue(atan(a)); | ||
414 | break; | 414 | break; | ||
415 | case Operator::arccot: | 415 | case Operator::arccot: | ||
416 | oper->setValue(log(a+pow(a*a+1., 0.5))); | 416 | oper->setValue(log(a+pow(a*a+1., 0.5))); | ||
417 | break; | 417 | break; | ||
418 | case Operator::arcsinh: //see http://en.wikipedia.org/wiki/Inverse_hyperbolic_function | 418 | case Operator::arcsinh: //see https://en.wikipedia.org/wiki/Inverse_hyperbolic_function | ||
419 | oper->setValue(asinh(a)); | 419 | oper->setValue(asinh(a)); | ||
420 | break; | 420 | break; | ||
421 | case Operator::arccosh: | 421 | case Operator::arccosh: | ||
422 | oper->setValue(acosh(a)); | 422 | oper->setValue(acosh(a)); | ||
423 | break; | 423 | break; | ||
424 | case Operator::arccsc: | 424 | case Operator::arccsc: | ||
425 | oper->setValue(1/asin(a)); | 425 | oper->setValue(1/asin(a)); | ||
426 | break; | 426 | break; | ||
▲ Show 20 Lines • Show All 403 Lines • ▼ Show 20 Line(s) | 829 | if (exp <= MAX_EXPONENT) { // then: use Addition-chain exponentiation | |||
830 | const int len = additionChains[exp][0]; | 830 | const int len = additionChains[exp][0]; | ||
831 | int i, j, k; | 831 | int i, j, k; | ||
832 | QVector<Matrix*> products(len+1); | 832 | QVector<Matrix*> products(len+1); | ||
833 | products[0] = base; | 833 | products[0] = base; | ||
834 | 834 | | |||
835 | if (exp>1) | 835 | if (exp>1) | ||
836 | products[1] = static_cast<Matrix*>(reduceMatrixMatrix(Operator::times, matrix, matrix, correct)); | 836 | products[1] = static_cast<Matrix*>(reduceMatrixMatrix(Operator::times, matrix, matrix, correct)); | ||
837 | 837 | | |||
838 | //NOTE see http://rosettacode.org/wiki/Addition-chain_exponentiation#C for more details | 838 | //NOTE see https://rosettacode.org/wiki/Addition-chain_exponentiation#C for more details | ||
839 | for (i = 2; i <= len; ++i) | 839 | for (i = 2; i <= len; ++i) | ||
840 | for (j = i - 1; j; --j) | 840 | for (j = i - 1; j; --j) | ||
841 | for (k = j; k >= 0; --k) | 841 | for (k = j; k >= 0; --k) | ||
842 | { | 842 | { | ||
843 | if (additionChains[exp][k+1] + additionChains[exp][j+1] < additionChains[exp][i+1]) break; | 843 | if (additionChains[exp][k+1] + additionChains[exp][j+1] < additionChains[exp][i+1]) break; | ||
844 | if (additionChains[exp][k+1] + additionChains[exp][j+1] > additionChains[exp][i+1]) continue; | 844 | if (additionChains[exp][k+1] + additionChains[exp][j+1] > additionChains[exp][i+1]) continue; | ||
845 | products[i] = static_cast<Matrix*>(reduceMatrixMatrix(Operator::times, products[j], products[k], correct)); | 845 | products[i] = static_cast<Matrix*>(reduceMatrixMatrix(Operator::times, products[j], products[k], correct)); | ||
846 | j = 1; | 846 | j = 1; | ||
▲ Show 20 Lines • Show All 326 Lines • Show Last 20 Lines |