Function: calcFunc-sec

calcFunc-sec is an autoloaded and byte-compiled function defined in calc-math.el.gz.

Signature

(calcFunc-sec X)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-math.el.gz
(defun calcFunc-sec (x)
  (cond ((and (integerp x)
              (eq calc-angle-mode 'deg)
              (= (% x 180) 0))
         (if (= (% x 360) 0)
             1
           -1))
        ((and (integerp x)
              (eq calc-angle-mode 'rad)
              (= x 0))
         1)
        ((Math-scalarp x)
         (math-with-extra-prec 2
           (math-sec-raw (math-to-radians (math-float x)))))
        ((eq (car x) 'sdev)
         (if (math-constp x)
             (math-with-extra-prec 2
               (let* ((xx (math-to-radians (math-float (nth 1 x))))
                      (xs (math-to-radians (math-float (nth 2 x))))
                      (sc (math-sin-cos-raw xx)))
                 (if (and (math-zerop (cdr sc))
                          (not calc-infinite-mode))
                     (progn
                       (calc-record-why "*Division by zero")
                       (list 'calcFunc-sec x))
                   (math-make-sdev (math-div-float '(float 1 0) (cdr sc))
                                   (math-div-float
                                    (math-mul xs (car sc))
                                    (math-sqr (cdr sc)))))))
           (math-make-sdev (calcFunc-sec (nth 1 x))
                           (math-div
                            (math-mul (nth 2 x)
                                      (calcFunc-sin (nth 1 x)))
                            (math-sqr (calcFunc-cos (nth 1 x)))))))
        ((and (eq (car x) 'intv)
              (math-intv-constp x))
         (math-with-extra-prec 2
           (let* ((xx (math-to-radians (math-float x)))
                  (na (math-floor (math-div (math-sub (nth 2 xx)
                                                      (math-pi-over-2))
                                            (math-pi))))
                  (nb (math-floor (math-div (math-sub (nth 3 xx)
                                                      (math-pi-over-2))
                                            (math-pi))))
                  (naa (math-floor (math-div (nth 2 xx) (math-pi-over-2))))
                  (nbb (math-floor (math-div (nth 3 xx) (math-pi-over-2))))
                  (span (math-sub nbb naa)))
             (if (not (equal na nb))
                 '(intv 3 (neg (var inf var-inf)) (var inf var-inf))
               (let ((int (math-sort-intv (nth 1 x)
                                          (math-sec-raw (nth 2 xx))
                                          (math-sec-raw (nth 3 xx)))))
                 (if (eq span 1)
                     (if (math-evenp (math-div (math-add naa 1) 2))
                         (math-make-intv (logior (nth 1 int) 2)
                                         1
                                         (nth 3 int))
                       (math-make-intv (logior (nth 1 int) 1)
                                       (nth 2 int)
                                       -1))
                   int))))))
        ((equal x '(var nan var-nan))
         x)
        (t (calc-record-why 'scalarp x)
           (list 'calcFunc-sec x))))