<< QD: 32 bytes decimal arithmetics | QD: 32 bytes decimal arithmetics | exp >>

DD_QD (MuPAT) >> DD_QD (MuPAT) > QD: 32 bytes decimal arithmetics > qd

# qd

builds an array of QD numbers

### Syntax

    a = qd(a0)
    a = qd(a0,a1)
    a = qd(a0,a1,a2)
    a = qd(a0,a1,a2,a3)

### Parameters

a0,a1,a2,a3

  arrays of decimal numbers, of same sizes

a

  array of QD numbers, of size(a0)

### Description

- Generate QD number using double precision numbers. The author applied overloading to basic arithmetic operations and several Scilab functions.

### Examples

    // define qd variables
    a = qd(1)
    b = qdrand(1,1) //// random value generator
    c = 3
    d = qd(c)
    A = [1,2;3,4]
    B = qd(A)
    // ---------------------------------------------
    // four basic arithmetic for qd
    a + b
    b + 1
    2 + b
    C = qdrand(2,2)
    A + C
    -b
    a - b
    b - 4
    c - b
    C - A
    b * d // scalar * scalar
    2 * b
    3 * A // scalar * matrix
    A * C // matrix * matrix
    a / b
    a / 3
    5 / b
    A / 3
    // ---------------------------------------------
    // relational operators for qd
    a == b
    a ~= b
    a <> b
    a > b
    a < b
    a >= b
    a <= b
    a == 1
    b ~= 2
    a <> 1
    b < 2
    b <= 3
    b > 3
    b >= -1
    5 < b
    2.2 <= b
    2.1 > b
    2 >= b

    // ---------------------------------------------
    // available functions for qd

    // square root
    a = qd(2)
    b = sqrt(a)

    //n-th root: not yet implemented
    //b = qdnrt(a,3)

    //absolute value
    c = -b
    abs(c)

    // cealing,floor
    d = b*10
    ceil(d)
    floor(d)

    //sin,cos,tan
    sin(d)
    cos(d)
    tan(d)

    // matrix functions
    A = qdrand(3,3)
    A(2,1) //extraction
    v = A(:,2)
    A(2,1) = qd(5) // insertion
    A(3,:) = qdrand(1,3)

    norm(v,2)

    B = qdrand(3,3)
    [L,U] = lu(B)
    [Q,R] = qr(B)

### See Also

- dd — builds an array of DD numbers

### Authors

Copyright (C) 2011 - Tsubasa Saito

Report an issue
<< QD: 32 bytes decimal arithmetics | QD: 32 bytes decimal arithmetics | exp >>