Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for basicSqr (0.09 sec)

  1. src/math/big/calibrate_test.go

    // Calculates lower and upper thresholds for when basicSqr
    // is faster than standard multiplication.
    
    // Usage: go test -run='^TestCalibrate$' -v -calibrate
    
    package big
    
    import (
    	"flag"
    	"fmt"
    	"testing"
    	"time"
    )
    
    var calibrate = flag.Bool("calibrate", false, "run calibration test")
    
    const (
    	sqrModeMul       = "mul(x, x)"
    	sqrModeBasic     = "basicSqr(x)"
    	sqrModeKaratsuba = "karatsubaSqr(x)"
    )
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Sep 05 23:35:29 UTC 2023
    - 4.6K bytes
    - Viewed (0)
  2. src/math/big/nat.go

    			addAt(z, t, i+k)
    		}
    
    		putNat(tp)
    	}
    
    	return z.norm()
    }
    
    // basicSqr sets z = x*x and is asymptotically faster than basicMul
    // by about a factor of 2, but slower for small arguments due to overhead.
    // Requirements: len(x) > 0, len(z) == 2*len(x)
    // The (non-normalized) result is placed in z.
    func basicSqr(z, x nat) {
    	n := len(x)
    	tp := getNat(2 * n)
    	t := *tp // temporary variable to hold the products
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 13 21:31:58 UTC 2024
    - 31.7K bytes
    - Viewed (0)
  3. src/math/big/nat_test.go

    			}
    		}
    	}
    }
    
    func testSqr(t *testing.T, x nat) {
    	got := make(nat, 2*len(x))
    	want := make(nat, 2*len(x))
    	got = got.sqr(x)
    	want = want.mul(x, x)
    	if got.cmp(want) != 0 {
    		t.Errorf("basicSqr(%v), got %v, want %v", x, got, want)
    	}
    }
    
    func TestSqr(t *testing.T) {
    	for _, a := range prodNN {
    		if a.x != nil {
    			testSqr(t, a.x)
    		}
    		if a.y != nil {
    			testSqr(t, a.y)
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jan 09 15:29:36 UTC 2024
    - 26.2K bytes
    - Viewed (0)
Back to top