Lines Matching refs:Abs
20 abs nat // absolute value of the integer
32 if len(x.abs) == 0 {
48 z.abs = z.abs.setUint64(uint64(x))
55 z.abs = z.abs.setUint64(x)
68 z.abs = z.abs.set(x.abs)
80 return x.abs
84 // value to abs, interpreted as a little-endian Word slice, and returning
85 // z. The result and abs share the same underlying array.
88 func (z *Int) SetBits(abs []Word) *Int {
89 z.abs = nat(abs).norm()
94 // Abs sets z to |x| (the absolute value of x) and returns z.
95 func (z *Int) Abs(x *Int) *Int {
104 z.neg = len(z.abs) > 0 && !z.neg // 0 has no sign
114 z.abs = z.abs.add(x.abs, y.abs)
118 if x.abs.cmp(y.abs) >= 0 {
119 z.abs = z.abs.sub(x.abs, y.abs)
122 z.abs = z.abs.sub(y.abs, x.abs)
125 z.neg = len(z.abs) > 0 && neg // 0 has no sign
135 z.abs = z.abs.add(x.abs, y.abs)
139 if x.abs.cmp(y.abs) >= 0 {
140 z.abs = z.abs.sub(x.abs, y.abs)
143 z.abs = z.abs.sub(y.abs, x.abs)
146 z.neg = len(z.abs) > 0 && neg // 0 has no sign
156 z.abs = z.abs.mul(x.abs, y.abs)
157 z.neg = len(z.abs) > 0 && x.neg != y.neg // 0 has no sign
179 z.abs = z.abs.mulRange(uint64(a), uint64(b))
200 z.abs, _ = z.abs.div(nil, x.abs, y.abs)
201 z.neg = len(z.abs) > 0 && x.neg != y.neg // 0 has no sign
209 _, z.abs = nat(nil).div(z.abs, x.abs, y.abs)
210 z.neg = len(z.abs) > 0 && x.neg // 0 has no sign
227 z.abs, r.abs = z.abs.div(r.abs, x.abs, y.abs)
228 z.neg, r.neg = len(z.abs) > 0 && x.neg != y.neg, len(r.abs) > 0 && x.neg // 0 has no sign
254 if z == y || alias(z.abs, y.abs) {
286 if z == y || alias(z.abs, y.abs) {
315 r = x.abs.cmp(y.abs)
350 v := int64(low64(x.abs))
360 return low64(x.abs)
388 z.abs = z.abs.setBytes(buf)
395 buf := make([]byte, len(x.abs)*_S)
396 return buf[x.abs.bytes(buf):]
402 return x.abs.bitLen()
414 yWords = y.abs
420 mWords = m.abs // m.abs may be nil for m == 0
423 z.abs = z.abs.expNN(x.abs, yWords, mWords)
424 z.neg = len(z.abs) > 0 && x.neg && len(yWords) > 0 && yWords[0]&1 == 1 // 0 has no sign
427 z.abs = z.abs.sub(mWords, z.abs) // z == x**y mod |m| && 0 <= z < |m|
466 for len(B.abs) > 0 {
505 case len(a.abs) > len(b.abs):
509 case len(a.abs) < len(b.abs):
519 if len(v.abs) == 0 {
525 k := u.abs.trailingZeroBits()
526 if vk := v.abs.trailingZeroBits(); vk < k {
534 if u.abs[0]&1 != 0 {
541 for len(t.abs) > 0 {
543 t.Rsh(t, t.abs.trailingZeroBits())
546 v.neg = len(v.abs) > 0 && !v.neg // 0 has no sign
559 if n.neg == true || len(n.abs) == 0 {
560 z.abs = nil
563 z.abs = z.abs.random(rnd, n.abs, n.abs.bitLen())
589 if len(y.abs) == 0 || y.abs[0]&1 == 0 {
613 if len(a.abs) == 0 {
617 if len(a.abs) == 0 {
623 s := a.abs.trailingZeroBits()
625 bmod8 := b.abs[0] & 7
633 if b.abs[0]&3 == 3 && c.abs[0]&3 == 3 {
661 e := s.abs.trailingZeroBits()
722 if len(p.abs) > 0 && p.abs[0]%4 == 3 {
731 z.abs = z.abs.shl(x.abs, n)
740 t := z.abs.sub(x.abs, natOne) // no underflow because |x| > 0
742 z.abs = t.add(t, natOne)
747 z.abs = z.abs.shr(x.abs, n)
757 if len(x.abs) > 0 {
758 return uint(x.abs[0] & 1) // bit 0 is same for -x
766 t := nat(nil).sub(x.abs, natOne)
770 return x.abs.bit(uint(i))
782 t := z.abs.sub(x.abs, natOne)
784 z.abs = t.add(t, natOne)
785 z.neg = len(z.abs) > 0
788 z.abs = z.abs.setBit(x.abs, uint(i), b)
798 x1 := nat(nil).sub(x.abs, natOne)
799 y1 := nat(nil).sub(y.abs, natOne)
800 z.abs = z.abs.add(z.abs.or(x1, y1), natOne)
806 z.abs = z.abs.and(x.abs, y.abs)
817 y1 := nat(nil).sub(y.abs, natOne)
818 z.abs = z.abs.andNot(x.abs, y1)
828 x1 := nat(nil).sub(x.abs, natOne)
829 y1 := nat(nil).sub(y.abs, natOne)
830 z.abs = z.abs.andNot(y1, x1)
836 z.abs = z.abs.andNot(x.abs, y.abs)
843 x1 := nat(nil).sub(x.abs, natOne)
844 z.abs = z.abs.add(z.abs.or(x1, y.abs), natOne)
850 y1 := nat(nil).sub(y.abs, natOne)
851 z.abs = z.abs.and(x.abs, y1)
861 x1 := nat(nil).sub(x.abs, natOne)
862 y1 := nat(nil).sub(y.abs, natOne)
863 z.abs = z.abs.add(z.abs.and(x1, y1), natOne)
869 z.abs = z.abs.or(x.abs, y.abs)
880 y1 := nat(nil).sub(y.abs, natOne)
881 z.abs = z.abs.add(z.abs.andNot(y1, x.abs), natOne)
891 x1 := nat(nil).sub(x.abs, natOne)
892 y1 := nat(nil).sub(y.abs, natOne)
893 z.abs = z.abs.xor(x1, y1)
899 z.abs = z.abs.xor(x.abs, y.abs)
910 y1 := nat(nil).sub(y.abs, natOne)
911 z.abs = z.abs.add(z.abs.xor(x.abs, y1), natOne)
920 z.abs = z.abs.sub(x.abs, natOne)
926 z.abs = z.abs.add(x.abs, natOne)
938 z.abs = z.abs.sqrt(x.abs)