gonum.org/v1/gonum@v0.14.0/blas/testblas/level1double.go (about)

     1  // Copyright ©2015 The Gonum Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package testblas
     6  
     7  import (
     8  	"fmt"
     9  	"math"
    10  	"testing"
    11  
    12  	"gonum.org/v1/gonum/blas"
    13  	"gonum.org/v1/gonum/floats"
    14  	"gonum.org/v1/gonum/floats/scalar"
    15  )
    16  
    17  type DoubleOneVectorCase struct {
    18  	Name       string
    19  	X          []float64
    20  	Incx       int
    21  	N          int
    22  	Panic      bool
    23  	Dasum      float64
    24  	Dnrm2      float64
    25  	Idamax     int
    26  	DscalCases []DScalCase
    27  }
    28  
    29  type DScalCase struct {
    30  	Alpha float64
    31  	Ans   []float64
    32  	Name  string
    33  }
    34  
    35  var DoubleOneVectorCases = []DoubleOneVectorCase{
    36  	{
    37  		Name:   "AllPositive",
    38  		X:      []float64{6, 5, 4, 2, 6},
    39  		Incx:   1,
    40  		N:      5,
    41  		Panic:  false,
    42  		Dasum:  23,
    43  		Dnrm2:  10.81665382639196787935766380241148783875388972153573863813135,
    44  		Idamax: 0,
    45  		DscalCases: []DScalCase{
    46  			{
    47  				Alpha: 0,
    48  				Ans:   []float64{0, 0, 0, 0, 0},
    49  			},
    50  			{
    51  				Alpha: 1,
    52  				Ans:   []float64{6, 5, 4, 2, 6},
    53  			},
    54  			{
    55  				Alpha: -2,
    56  				Ans:   []float64{-12, -10, -8, -4, -12},
    57  			},
    58  		},
    59  	},
    60  	{
    61  		Name:   "LeadingZero",
    62  		X:      []float64{0, 1},
    63  		Incx:   1,
    64  		N:      2,
    65  		Panic:  false,
    66  		Dasum:  1,
    67  		Dnrm2:  1,
    68  		Idamax: 1,
    69  		DscalCases: []DScalCase{
    70  			{
    71  				Alpha: 0,
    72  				Ans:   []float64{0, 0},
    73  			},
    74  			{
    75  				Alpha: 1,
    76  				Ans:   []float64{0, 1},
    77  			},
    78  			{
    79  				Alpha: -2,
    80  				Ans:   []float64{0, -2},
    81  			},
    82  		},
    83  	},
    84  	{
    85  		Name:   "MaxInMiddle",
    86  		X:      []float64{6, 5, 9, 0, 6},
    87  		Incx:   1,
    88  		N:      5,
    89  		Panic:  false,
    90  		Dasum:  26,
    91  		Dnrm2:  13.34166406412633371248943627250846646911846482744007727141318,
    92  		Idamax: 2,
    93  		DscalCases: []DScalCase{
    94  			{
    95  				Alpha: -2,
    96  				Ans:   []float64{-12, -10, -18, 0, -12},
    97  			},
    98  		},
    99  	},
   100  	{
   101  		Name:   "MaxAtEnd",
   102  		X:      []float64{6, 5, -9, 0, 10},
   103  		Incx:   1,
   104  		N:      5,
   105  		Panic:  false,
   106  		Dasum:  30,
   107  		Dnrm2:  15.55634918610404553681857596630667886426639062914642880494347,
   108  		Idamax: 4,
   109  		DscalCases: []DScalCase{
   110  			{
   111  				Alpha: -2,
   112  				Ans:   []float64{-12, -10, 18, 0, -20},
   113  			},
   114  		},
   115  	},
   116  	{
   117  		Name:   "AllNegative",
   118  		X:      []float64{-6, -5, -4, -2, -6},
   119  		Incx:   1,
   120  		N:      5,
   121  		Panic:  false,
   122  		Dasum:  23,
   123  		Dnrm2:  10.81665382639196787935766380241148783875388972153573863813135,
   124  		Idamax: 0,
   125  		DscalCases: []DScalCase{
   126  			{
   127  				Alpha: -2,
   128  				Ans:   []float64{12, 10, 8, 4, 12},
   129  			},
   130  		},
   131  	},
   132  	{
   133  		Name:   "AllMixed",
   134  		X:      []float64{-6, 5, 4, -2, -6},
   135  		Incx:   1,
   136  		N:      5,
   137  		Panic:  false,
   138  		Dasum:  23,
   139  		Dnrm2:  10.81665382639196787935766380241148783875388972153573863813135,
   140  		Idamax: 0,
   141  		DscalCases: []DScalCase{
   142  			{
   143  				Alpha: -2,
   144  				Ans:   []float64{12, -10, -8, 4, 12},
   145  			},
   146  		},
   147  	},
   148  	{
   149  		Name:   "ZeroN",
   150  		X:      []float64{-6, 5, 4, -2, -6},
   151  		Incx:   1,
   152  		N:      0,
   153  		Panic:  false,
   154  		Dasum:  0,
   155  		Dnrm2:  0,
   156  		Idamax: -1,
   157  		DscalCases: []DScalCase{
   158  			{
   159  				Alpha: -2,
   160  				Ans:   []float64{-6, 5, 4, -2, -6},
   161  			},
   162  		},
   163  	},
   164  	{
   165  		Name:   "OneN",
   166  		X:      []float64{-6, 5, 4, -2, -6},
   167  		Incx:   1,
   168  		N:      1,
   169  		Panic:  false,
   170  		Dasum:  6,
   171  		Dnrm2:  6,
   172  		Idamax: 0,
   173  		DscalCases: []DScalCase{
   174  			{
   175  				Alpha: -2,
   176  				Ans:   []float64{12, 5, 4, -2, -6},
   177  			},
   178  		},
   179  	},
   180  	{
   181  		Name:   "PositiveExactInc",
   182  		X:      []float64{-6, 5, 10, -2, -5},
   183  		Incx:   2,
   184  		N:      3,
   185  		Panic:  false,
   186  		Dasum:  21,
   187  		Dnrm2:  12.68857754044952038019377274608948979173952662752515253090272,
   188  		Idamax: 1,
   189  		DscalCases: []DScalCase{
   190  			{
   191  				Alpha: -2,
   192  				Ans:   []float64{12, 5, -20, -2, 10},
   193  			},
   194  		},
   195  	},
   196  	{
   197  		Name:   "PositiveOffInc",
   198  		X:      []float64{-6, 5, 4, -2, -6, 8, 10, 11},
   199  		Incx:   3,
   200  		N:      3,
   201  		Panic:  false,
   202  		Dasum:  18,
   203  		Dnrm2:  11.83215956619923208513465658312323409683100246158868064575943,
   204  		Idamax: 2,
   205  		DscalCases: []DScalCase{
   206  			{
   207  				Alpha: -2,
   208  				Ans:   []float64{12, 5, 4, 4, -6, 8, -20, 11},
   209  			},
   210  		},
   211  	},
   212  	{
   213  		Name:   "PositiveShortInc",
   214  		X:      []float64{-6, 5, 4, -2, -6, 8, 10, 11},
   215  		Incx:   3,
   216  		N:      2,
   217  		Panic:  false,
   218  		Dasum:  8,
   219  		Dnrm2:  6.324555320336758663997787088865437067439110278650433653715009,
   220  		Idamax: 0,
   221  		DscalCases: []DScalCase{
   222  			{
   223  				Alpha: -2,
   224  				Ans:   []float64{12, 5, 4, 4, -6, 8, 10, 11},
   225  			},
   226  		},
   227  	},
   228  	{
   229  		Name:   "NegativeInc",
   230  		X:      []float64{-6, 5, 4, -2, -6},
   231  		Incx:   -1,
   232  		N:      5,
   233  		Panic:  false,
   234  		Dasum:  0,
   235  		Dnrm2:  0,
   236  		Idamax: -1,
   237  		DscalCases: []DScalCase{
   238  			{
   239  				Alpha: -2,
   240  				Ans:   []float64{-6, 5, 4, -2, -6},
   241  			},
   242  		},
   243  	},
   244  	{
   245  		Name:   "NegativeExactInc",
   246  		X:      []float64{-6, 5, 4, -2, -6},
   247  		Incx:   -2,
   248  		N:      3,
   249  		Panic:  false,
   250  		Dasum:  0,
   251  		Dnrm2:  0,
   252  		Idamax: -1,
   253  		DscalCases: []DScalCase{
   254  			{
   255  				Alpha: -2,
   256  				Ans:   []float64{-6, 5, 4, -2, -6},
   257  			},
   258  		},
   259  	},
   260  	{
   261  		Name:   "NegativeOffInc",
   262  		X:      []float64{-6, 5, 4, -2, -6, 8, 10, 11},
   263  		Incx:   -3,
   264  		N:      2,
   265  		Panic:  false,
   266  		Dasum:  0,
   267  		Dnrm2:  0,
   268  		Idamax: -1,
   269  		DscalCases: []DScalCase{
   270  			{
   271  				Alpha: -2,
   272  				Ans:   []float64{-6, 5, 4, -2, -6, 8, 10, 11},
   273  			},
   274  		},
   275  	},
   276  	{
   277  		Name:   "NegativeShortInc",
   278  		X:      []float64{-6, 5, 4, -2, -6, 8, 10, 11},
   279  		Incx:   -3,
   280  		N:      2,
   281  		Panic:  false,
   282  		Dasum:  0,
   283  		Dnrm2:  0,
   284  		Idamax: -1,
   285  		DscalCases: []DScalCase{
   286  			{
   287  				Alpha: -2,
   288  				Ans:   []float64{-6, 5, 4, -2, -6, 8, 10, 11},
   289  			},
   290  		},
   291  	},
   292  	{
   293  		Name:  "NegativeN",
   294  		X:     []float64{-6, 5, 4, -2, -6},
   295  		Incx:  2,
   296  		N:     -5,
   297  		Panic: true,
   298  		DscalCases: []DScalCase{
   299  			{
   300  				Alpha: -2,
   301  				Ans:   []float64{-6, 5, 4, -2, -6},
   302  			},
   303  		},
   304  	},
   305  	{
   306  		Name:  "ZeroInc",
   307  		X:     []float64{-6, 5, 4, -2, -6},
   308  		Incx:  0,
   309  		N:     5,
   310  		Panic: true,
   311  		DscalCases: []DScalCase{
   312  			{
   313  				Alpha: -2,
   314  				Ans:   []float64{-6, 5, 4, -2, -6},
   315  			},
   316  		},
   317  	},
   318  	{
   319  		Name:  "OutOfBounds",
   320  		X:     []float64{-6, 5, 4, -2, -6},
   321  		Incx:  2,
   322  		N:     6,
   323  		Panic: true,
   324  		DscalCases: []DScalCase{
   325  			{
   326  				Alpha: -2,
   327  				Ans:   []float64{-6, 5, 4, -2, -6},
   328  			},
   329  		},
   330  	},
   331  	{
   332  		Name:   "NegativeOutOfBounds",
   333  		X:      []float64{-6, 5, 4, -2, -6},
   334  		Incx:   -2,
   335  		N:      6,
   336  		Panic:  false,
   337  		Dasum:  0,
   338  		Dnrm2:  0,
   339  		Idamax: -1,
   340  		DscalCases: []DScalCase{
   341  			{
   342  				Alpha: -2,
   343  				Ans:   []float64{-6, 5, 4, -2, -6},
   344  			},
   345  		},
   346  	},
   347  	{
   348  		Name:   "NaN",
   349  		X:      []float64{math.NaN(), 2.0},
   350  		Incx:   1,
   351  		N:      2,
   352  		Panic:  false,
   353  		Dasum:  math.NaN(),
   354  		Dnrm2:  math.NaN(),
   355  		Idamax: 0,
   356  		DscalCases: []DScalCase{
   357  			{
   358  				Alpha: -2,
   359  				Ans:   []float64{math.NaN(), -4.0},
   360  			},
   361  			{
   362  				Alpha: 0,
   363  				Ans:   []float64{0, 0},
   364  			},
   365  		},
   366  	},
   367  	{
   368  		Name:   "NaNInc",
   369  		X:      []float64{math.NaN(), math.NaN(), 2.0},
   370  		Incx:   2,
   371  		N:      2,
   372  		Panic:  false,
   373  		Dasum:  math.NaN(),
   374  		Dnrm2:  math.NaN(),
   375  		Idamax: 0,
   376  		DscalCases: []DScalCase{
   377  			{
   378  				Alpha: -2,
   379  				Ans:   []float64{math.NaN(), math.NaN(), -4.0},
   380  			},
   381  			{
   382  				Alpha: 0,
   383  				Ans:   []float64{0, math.NaN(), 0},
   384  			},
   385  		},
   386  	},
   387  	{
   388  		Name:   "Empty",
   389  		X:      []float64{},
   390  		Incx:   1,
   391  		N:      0,
   392  		Panic:  false,
   393  		Dasum:  0,
   394  		Dnrm2:  0,
   395  		Idamax: -1,
   396  		DscalCases: []DScalCase{
   397  			{
   398  				Alpha: -2,
   399  				Ans:   []float64{},
   400  			},
   401  			{
   402  				Alpha: 0,
   403  				Ans:   []float64{},
   404  			},
   405  		},
   406  	},
   407  	{
   408  		Name:   "EmptyZeroInc",
   409  		X:      []float64{},
   410  		Incx:   0,
   411  		N:      0,
   412  		Panic:  true,
   413  		Dasum:  0,
   414  		Dnrm2:  0,
   415  		Idamax: -1,
   416  		DscalCases: []DScalCase{
   417  			{
   418  				Alpha: -2,
   419  				Ans:   []float64{},
   420  			},
   421  			{
   422  				Alpha: 0,
   423  				Ans:   []float64{},
   424  			},
   425  		},
   426  	},
   427  	{
   428  		Name:   "EmptyReverse",
   429  		X:      []float64{},
   430  		Incx:   -1,
   431  		N:      0,
   432  		Panic:  false,
   433  		Dasum:  0,
   434  		Dnrm2:  0,
   435  		Idamax: -1,
   436  		DscalCases: []DScalCase{
   437  			{
   438  				Alpha: -2,
   439  				Ans:   []float64{},
   440  			},
   441  			{
   442  				Alpha: 0,
   443  				Ans:   []float64{},
   444  			},
   445  		},
   446  	},
   447  	{
   448  		Name:   "MultiInf",
   449  		X:      []float64{5, math.Inf(1), math.Inf(-1), 8, 9},
   450  		Incx:   1,
   451  		N:      5,
   452  		Panic:  false,
   453  		Dasum:  math.Inf(1),
   454  		Dnrm2:  math.Inf(1),
   455  		Idamax: 1,
   456  		DscalCases: []DScalCase{
   457  			{
   458  				Alpha: -2,
   459  				Ans:   []float64{-10, math.Inf(-1), math.Inf(1), -16, -18},
   460  			},
   461  			{
   462  				Alpha: 0,
   463  				Ans:   []float64{0, 0, 0, 0, 0},
   464  			},
   465  		},
   466  	},
   467  	{
   468  		Name:   "NaNInf",
   469  		X:      []float64{5, math.NaN(), math.Inf(-1), 8, 9},
   470  		Incx:   1,
   471  		N:      5,
   472  		Panic:  false,
   473  		Dasum:  math.NaN(),
   474  		Dnrm2:  math.NaN(),
   475  		Idamax: 2,
   476  		DscalCases: []DScalCase{
   477  			{
   478  				Alpha: -2,
   479  				Ans:   []float64{-10, math.NaN(), math.Inf(1), -16, -18},
   480  			},
   481  			{
   482  				Alpha: 0,
   483  				Ans:   []float64{0, 0, 0, 0, 0},
   484  			},
   485  		},
   486  	},
   487  	{
   488  		Name:   "InfNaN",
   489  		X:      []float64{5, math.Inf(1), math.NaN(), 8, 9},
   490  		Incx:   1,
   491  		N:      5,
   492  		Panic:  false,
   493  		Dasum:  math.NaN(),
   494  		Dnrm2:  math.NaN(),
   495  		Idamax: 1,
   496  		DscalCases: []DScalCase{
   497  			{
   498  				Alpha: -2,
   499  				Ans:   []float64{-10, math.Inf(-1), math.NaN(), -16, -18},
   500  			},
   501  			{
   502  				Alpha: 0,
   503  				Ans:   []float64{0, 0, 0, 0, 0},
   504  			},
   505  		},
   506  	},
   507  }
   508  
   509  type DoubleTwoVectorCase struct {
   510  	Name  string
   511  	X     []float64
   512  	Y     []float64
   513  	XTmp  []float64
   514  	YTmp  []float64
   515  	Incx  int
   516  	Incy  int
   517  	N     int
   518  	Panic bool
   519  	// For Daxpy
   520  	DaxpyCases []DaxpyCase
   521  	DdotAns    float64
   522  	DswapAns   DTwoVecAnswer
   523  	DcopyAns   DTwoVecAnswer
   524  	DrotCases  []DrotCase
   525  	DrotmCases []DrotmCase
   526  }
   527  
   528  type DaxpyCase struct {
   529  	Alpha float64
   530  	Ans   []float64
   531  }
   532  
   533  type DrotCase struct {
   534  	C    float64
   535  	S    float64
   536  	XAns []float64
   537  	YAns []float64
   538  }
   539  
   540  type DrotmCase struct {
   541  	P    blas.DrotmParams
   542  	XAns []float64
   543  	YAns []float64
   544  	Name string
   545  }
   546  
   547  type DTwoVecAnswer struct {
   548  	X []float64
   549  	Y []float64
   550  }
   551  
   552  var DoubleTwoVectorCases = []DoubleTwoVectorCase{
   553  	{
   554  		Name:  "UnitaryInc",
   555  		X:     []float64{10, 15, -6, 3, 14, 7},
   556  		Y:     []float64{8, -2, 4, 7, 6, -3},
   557  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
   558  		YTmp:  []float64{0, 0, 0, 0, 0, 0},
   559  		Incx:  1,
   560  		Incy:  1,
   561  		N:     6,
   562  		Panic: false,
   563  		DaxpyCases: []DaxpyCase{
   564  			{
   565  				Alpha: 1,
   566  				Ans:   []float64{18, 13, -2, 10, 20, 4},
   567  			},
   568  			{
   569  				Alpha: 2,
   570  				Ans:   []float64{28, 28, -8, 13, 34, 11},
   571  			},
   572  			{
   573  				Alpha: -3,
   574  				Ans:   []float64{-22, -47, 22, -2, -36, -24},
   575  			},
   576  			{
   577  				Alpha: 0,
   578  				Ans:   []float64{8, -2, 4, 7, 6, -3},
   579  			},
   580  		},
   581  		DdotAns: 110,
   582  		DswapAns: DTwoVecAnswer{
   583  			X: []float64{8, -2, 4, 7, 6, -3},
   584  			Y: []float64{10, 15, -6, 3, 14, 7},
   585  		},
   586  		DcopyAns: DTwoVecAnswer{
   587  			X: []float64{10, 15, -6, 3, 14, 7},
   588  			Y: []float64{10, 15, -6, 3, 14, 7},
   589  		},
   590  		DrotCases: []DrotCase{
   591  			{
   592  				C:    math.Cos(0),
   593  				S:    math.Sin(0),
   594  				XAns: []float64{10, 15, -6, 3, 14, 7},
   595  				YAns: []float64{8, -2, 4, 7, 6, -3},
   596  			},
   597  			{
   598  				C:    math.Cos(25 * math.Pi / 180),
   599  				S:    math.Sin(25 * math.Pi / 180),
   600  				XAns: []float64{12.444023964292095, 12.749380282068351, -3.7473736752571014, 5.677251193294846, 15.224018588957296, 5.076299724034451},
   601  				YAns: []float64{3.024279678886205, -8.151889500183792, 6.160940718590796, 5.076299724034451, -0.4788089421498931, -5.677251193294846},
   602  			},
   603  			{
   604  				C:    math.Cos(0.5 * math.Pi),
   605  				S:    math.Sin(0.5 * math.Pi),
   606  				XAns: []float64{8, -2, 4, 7, 6, -3},
   607  				YAns: []float64{-10, -15, 6, -3, -14, -7},
   608  			},
   609  			{
   610  				C:    math.Cos(math.Pi),
   611  				S:    math.Sin(math.Pi),
   612  				XAns: []float64{-10, -15, 6, -3, -14, -7},
   613  				YAns: []float64{-8, 2, -4, -7, -6, 3},
   614  			},
   615  		},
   616  		DrotmCases: []DrotmCase{
   617  			{
   618  				P: blas.DrotmParams{
   619  					Flag: blas.Identity,
   620  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
   621  				},
   622  				XAns: []float64{10, 15, -6, 3, 14, 7},
   623  				YAns: []float64{8, -2, 4, 7, 6, -3},
   624  				Name: "Neg2Flag",
   625  			},
   626  			{
   627  				P: blas.DrotmParams{
   628  					Flag: blas.Rescaling,
   629  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
   630  				},
   631  				XAns: []float64{8.2, 13.7, -5.8, 2, 12, 6.6},
   632  				YAns: []float64{5, 0.5, 1.4, 3.8, 4.4, -0.8},
   633  				Name: "Neg1Flag",
   634  			},
   635  			{
   636  				P: blas.DrotmParams{
   637  					Flag: blas.OffDiagonal,
   638  					H:    [4]float64{1, 0.1, -0.1, 1},
   639  				},
   640  				XAns: []float64{9.2, 15.2, -6.4, 2.3, 13.4, 7.3},
   641  				YAns: []float64{9, -0.5, 3.4, 7.3, 7.4, -2.3},
   642  				Name: "ZeroFlag",
   643  			},
   644  			{
   645  				P: blas.DrotmParams{
   646  					Flag: blas.Diagonal,
   647  					H:    [4]float64{0.5, -1, 1, 0.7},
   648  				},
   649  				XAns: []float64{13, 5.5, 1, 8.5, 13, 0.5},
   650  				YAns: []float64{-4.4, -16.4, 8.8, 1.9, -9.8, -9.1},
   651  				Name: "OneFlag",
   652  			},
   653  		},
   654  	},
   655  	{
   656  		Name:  "UnitaryIncLong",
   657  		X:     []float64{10, 15, -6, 3, 14, 7, 8, -9, 10},
   658  		Y:     []float64{8, -2, 4, 7, 6, -3, 7, -6},
   659  		XTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0, 0},
   660  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
   661  		Incx:  1,
   662  		Incy:  1,
   663  		N:     6,
   664  		Panic: false,
   665  		DaxpyCases: []DaxpyCase{
   666  			{
   667  				Alpha: 1,
   668  				Ans:   []float64{18, 13, -2, 10, 20, 4, 7, -6},
   669  			},
   670  			{
   671  				Alpha: 2,
   672  				Ans:   []float64{28, 28, -8, 13, 34, 11, 7, -6},
   673  			},
   674  			{
   675  				Alpha: -3,
   676  				Ans:   []float64{-22, -47, 22, -2, -36, -24, 7, -6},
   677  			},
   678  			{
   679  				Alpha: 0,
   680  				Ans:   []float64{8, -2, 4, 7, 6, -3, 7, -6},
   681  			},
   682  		},
   683  		DdotAns: 110,
   684  		DswapAns: DTwoVecAnswer{
   685  			X: []float64{8, -2, 4, 7, 6, -3, 8, -9, 10},
   686  			Y: []float64{10, 15, -6, 3, 14, 7, 7, -6},
   687  		},
   688  		DcopyAns: DTwoVecAnswer{
   689  			X: []float64{10, 15, -6, 3, 14, 7, 8, -9, 10},
   690  			Y: []float64{10, 15, -6, 3, 14, 7, 7, -6},
   691  		},
   692  		DrotCases: []DrotCase{
   693  			{
   694  				C:    math.Cos(0),
   695  				S:    math.Sin(0),
   696  				XAns: []float64{10, 15, -6, 3, 14, 7, 8, -9, 10},
   697  				YAns: []float64{8, -2, 4, 7, 6, -3, 7, -6},
   698  			},
   699  			{
   700  				C:    math.Cos(25 * math.Pi / 180),
   701  				S:    math.Sin(25 * math.Pi / 180),
   702  				XAns: []float64{12.444023964292095, 12.749380282068351, -3.7473736752571014, 5.677251193294846, 15.224018588957296, 5.076299724034451, 8, -9, 10},
   703  				YAns: []float64{3.024279678886205, -8.151889500183792, 6.160940718590796, 5.076299724034451, -0.4788089421498931, -5.677251193294846, 7, -6},
   704  			},
   705  			{
   706  				C:    math.Cos(0.5 * math.Pi),
   707  				S:    math.Sin(0.5 * math.Pi),
   708  				XAns: []float64{8, -2, 4, 7, 6, -3, 8, -9, 10},
   709  				YAns: []float64{-10, -15, 6, -3, -14, -7, 7, -6},
   710  			},
   711  			{
   712  				C:    math.Cos(math.Pi),
   713  				S:    math.Sin(math.Pi),
   714  				XAns: []float64{-10, -15, 6, -3, -14, -7, 8, -9, 10},
   715  				YAns: []float64{-8, 2, -4, -7, -6, 3, 7, -6},
   716  			},
   717  		},
   718  		DrotmCases: []DrotmCase{
   719  			{
   720  				P: blas.DrotmParams{
   721  					Flag: blas.Identity,
   722  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
   723  				},
   724  				XAns: []float64{10, 15, -6, 3, 14, 7, 8, -9, 10},
   725  				YAns: []float64{8, -2, 4, 7, 6, -3, 7, -6},
   726  				Name: "Neg2Flag",
   727  			},
   728  			{
   729  				P: blas.DrotmParams{
   730  					Flag: blas.Rescaling,
   731  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
   732  				},
   733  				XAns: []float64{8.2, 13.7, -5.8, 2, 12, 6.6, 8, -9, 10},
   734  				YAns: []float64{5, 0.5, 1.4, 3.8, 4.4, -0.8, 7, -6},
   735  				Name: "Neg1Flag",
   736  			},
   737  			{
   738  				P: blas.DrotmParams{
   739  					Flag: blas.OffDiagonal,
   740  					H:    [4]float64{1, 0.1, -0.1, 1},
   741  				},
   742  				XAns: []float64{9.2, 15.2, -6.4, 2.3, 13.4, 7.3, 8, -9, 10},
   743  				YAns: []float64{9, -0.5, 3.4, 7.3, 7.4, -2.3, 7, -6},
   744  				Name: "ZeroFlag",
   745  			},
   746  			{
   747  				P: blas.DrotmParams{
   748  					Flag: blas.Diagonal,
   749  					H:    [4]float64{0.5, -1, 1, 0.7},
   750  				},
   751  				XAns: []float64{13, 5.5, 1, 8.5, 13, 0.5, 8, -9, 10},
   752  				YAns: []float64{-4.4, -16.4, 8.8, 1.9, -9.8, -9.1, 7, -6},
   753  				Name: "OneFlag",
   754  			},
   755  		},
   756  	},
   757  	{
   758  		Name:  "PositiveInc",
   759  		X:     []float64{10, 15, -6, 3, 14, 7},
   760  		Y:     []float64{8, -2, 4, 7, 6, -3, -4, 10},
   761  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
   762  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
   763  		Incx:  2,
   764  		Incy:  3,
   765  		N:     3,
   766  		Panic: false,
   767  		DaxpyCases: []DaxpyCase{
   768  			{
   769  				Alpha: 2,
   770  				Ans:   []float64{28, -2, 4, -5, 6, -3, 24, 10},
   771  			},
   772  		},
   773  		DdotAns: -18,
   774  		DswapAns: DTwoVecAnswer{
   775  			X: []float64{8, 15, 7, 3, -4, 7},
   776  			Y: []float64{10, -2, 4, -6, 6, -3, 14, 10},
   777  		},
   778  		DcopyAns: DTwoVecAnswer{
   779  			X: []float64{10, 15, -6, 3, 14, 7},
   780  			Y: []float64{10, -2, 4, -6, 6, -3, 14, 10},
   781  		},
   782  		DrotCases: []DrotCase{
   783  			{
   784  				C:    math.Cos(25 * math.Pi / 180),
   785  				S:    math.Sin(25 * math.Pi / 180),
   786  				XAns: []float64{12.444023964292095, 15, -2.479518890035003, 3, 10.997835971550302, 7},
   787  				YAns: []float64{3.024279678886205, -2, 4, 8.879864079700745, 6, -3, -9.541886812516392, 10},
   788  			},
   789  		},
   790  		DrotmCases: []DrotmCase{
   791  			{
   792  				P: blas.DrotmParams{
   793  					Flag: blas.Rescaling,
   794  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
   795  				},
   796  				XAns: []float64{8.2, 15, -6.1, 3, 13, 7},
   797  				YAns: []float64{5, -2, 4, 2.9, 6, -3, -0.6, 10},
   798  			},
   799  			{
   800  				P: blas.DrotmParams{
   801  					Flag: blas.OffDiagonal,
   802  					H:    [4]float64{1, 0.1, -0.1, 1},
   803  				},
   804  				XAns: []float64{9.2, 15, -6.7, 3, 14.4, 7},
   805  				YAns: []float64{9, -2, 4, 6.4, 6, -3, -2.6, 10},
   806  			},
   807  			{
   808  				P: blas.DrotmParams{
   809  					Flag: blas.Diagonal,
   810  					H:    [4]float64{0.5, -1, 1, 0.7},
   811  				},
   812  				XAns: []float64{13, 15, 4, 3, 3, 7},
   813  				YAns: []float64{-4.4, -2, 4, 10.9, 6, -3, -16.8, 10},
   814  			},
   815  		},
   816  	},
   817  	{
   818  		Name:  "NegativeInc",
   819  		X:     []float64{10, 15, -6, 3, 14, 7},
   820  		Y:     []float64{8, -2, 4, 7, 6, -3, -4, 10},
   821  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
   822  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
   823  		Incx:  -2,
   824  		Incy:  -3,
   825  		N:     3,
   826  		Panic: false,
   827  		DaxpyCases: []DaxpyCase{
   828  			{
   829  				Alpha: 2,
   830  				Ans:   []float64{28, -2, 4, -5, 6, -3, 24, 10},
   831  			},
   832  		},
   833  		DdotAns: -18,
   834  		DswapAns: DTwoVecAnswer{
   835  			X: []float64{8, 15, 7, 3, -4, 7},
   836  			Y: []float64{10, -2, 4, -6, 6, -3, 14, 10},
   837  		},
   838  		DcopyAns: DTwoVecAnswer{
   839  			X: []float64{10, 15, -6, 3, 14, 7},
   840  			Y: []float64{10, -2, 4, -6, 6, -3, 14, 10},
   841  		},
   842  		DrotCases: []DrotCase{
   843  			{
   844  				C:    math.Cos(25 * math.Pi / 180),
   845  				S:    math.Sin(25 * math.Pi / 180),
   846  				XAns: []float64{12.444023964292095, 15, -2.479518890035003, 3, 10.997835971550302, 7},
   847  				YAns: []float64{3.024279678886205, -2, 4, 8.879864079700745, 6, -3, -9.541886812516392, 10},
   848  			},
   849  		},
   850  		DrotmCases: []DrotmCase{
   851  			{
   852  				P: blas.DrotmParams{
   853  					Flag: blas.Rescaling,
   854  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
   855  				},
   856  				XAns: []float64{8.2, 15, -6.1, 3, 13, 7},
   857  				YAns: []float64{5, -2, 4, 2.9, 6, -3, -0.6, 10},
   858  			},
   859  			{
   860  				P: blas.DrotmParams{
   861  					Flag: blas.OffDiagonal,
   862  					H:    [4]float64{1, 0.1, -0.1, 1},
   863  				},
   864  				XAns: []float64{9.2, 15, -6.7, 3, 14.4, 7},
   865  				YAns: []float64{9, -2, 4, 6.4, 6, -3, -2.6, 10},
   866  			},
   867  			{
   868  				P: blas.DrotmParams{
   869  					Flag: blas.Diagonal,
   870  					H:    [4]float64{0.5, -1, 1, 0.7},
   871  				},
   872  				XAns: []float64{13, 15, 4, 3, 3, 7},
   873  				YAns: []float64{-4.4, -2, 4, 10.9, 6, -3, -16.8, 10},
   874  			},
   875  		},
   876  	},
   877  	{
   878  		Name:  "MixedInc1",
   879  		X:     []float64{10, 15, -6, 3, 14, 7},
   880  		Y:     []float64{8, -2, 4, 7, 6, -3, -4, 10},
   881  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
   882  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
   883  		Incx:  2,
   884  		Incy:  -3,
   885  		N:     3,
   886  		Panic: false,
   887  		DaxpyCases: []DaxpyCase{
   888  			{
   889  				Alpha: 2,
   890  				Ans:   []float64{36, -2, 4, -5, 6, -3, 16, 10},
   891  			},
   892  		},
   893  		DdotAns: 30,
   894  		DswapAns: DTwoVecAnswer{
   895  			X: []float64{-4, 15, 7, 3, 8, 7},
   896  			Y: []float64{14, -2, 4, -6, 6, -3, 10, 10},
   897  		},
   898  		DcopyAns: DTwoVecAnswer{
   899  			X: []float64{10, 15, -6, 3, 14, 7},
   900  			Y: []float64{14, -2, 4, -6, 6, -3, 10, 10},
   901  		},
   902  		DrotCases: []DrotCase{
   903  			{
   904  				C:    math.Cos(25 * math.Pi / 180),
   905  				S:    math.Sin(25 * math.Pi / 180),
   906  				XAns: []float64{7.372604823403701, 15, -2.479518890035003, 3, 16.069255112438693, 7},
   907  				YAns: []float64{1.333806631923407, -2, 4, 8.879864079700745, 6, -3, -7.851413765553595, 10},
   908  			},
   909  		},
   910  		DrotmCases: []DrotmCase{
   911  			{
   912  				P: blas.DrotmParams{
   913  					Flag: blas.Rescaling,
   914  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
   915  				},
   916  				XAns: []float64{9.4, 15, -6.1, 3, 11.8, 7},
   917  				YAns: []float64{5.4, -2, 4, 2.9, 6, -3, -1, 10},
   918  			},
   919  			{
   920  				P: blas.DrotmParams{
   921  					Flag: blas.OffDiagonal,
   922  					H:    [4]float64{1, 0.1, -0.1, 1},
   923  				},
   924  				XAns: []float64{10.4, 15, -6.7, 3, 13.2, 7},
   925  				YAns: []float64{9.4, -2, 4, 6.4, 6, -3, -3, 10},
   926  			},
   927  			{
   928  				P: blas.DrotmParams{
   929  					Flag: blas.Diagonal,
   930  					H:    [4]float64{0.5, -1, 1, 0.7},
   931  				},
   932  				XAns: []float64{1, 15, 4, 3, 15, 7},
   933  				YAns: []float64{-8.4, -2, 4, 10.9, 6, -3, -12.8, 10},
   934  			},
   935  		},
   936  	},
   937  	{
   938  		Name:  "MixedInc2",
   939  		X:     []float64{10, 15, -6, 3, 14, 7},
   940  		Y:     []float64{8, -2, 4, 7, 6, -3, -4, 10},
   941  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
   942  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
   943  		Incx:  -2,
   944  		Incy:  3,
   945  		N:     3,
   946  		Panic: false,
   947  		DaxpyCases: []DaxpyCase{
   948  			{
   949  				Alpha: 2,
   950  				Ans:   []float64{36, -2, 4, -5, 6, -3, 16, 10},
   951  			},
   952  		},
   953  		DdotAns: 30,
   954  		DswapAns: DTwoVecAnswer{
   955  			X: []float64{-4, 15, 7, 3, 8, 7},
   956  			Y: []float64{14, -2, 4, -6, 6, -3, 10, 10},
   957  		},
   958  		DcopyAns: DTwoVecAnswer{
   959  			X: []float64{10, 15, -6, 3, 14, 7},
   960  			Y: []float64{14, -2, 4, -6, 6, -3, 10, 10},
   961  		},
   962  		DrotCases: []DrotCase{
   963  			{
   964  				C:    math.Cos(25 * math.Pi / 180),
   965  				S:    math.Sin(25 * math.Pi / 180),
   966  				XAns: []float64{7.372604823403701, 15, -2.479518890035003, 3, 16.069255112438693, 7},
   967  				YAns: []float64{1.333806631923407, -2, 4, 8.879864079700745, 6, -3, -7.851413765553595, 10},
   968  			},
   969  		},
   970  		DrotmCases: []DrotmCase{
   971  			{
   972  				P: blas.DrotmParams{
   973  					Flag: blas.Rescaling,
   974  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
   975  				},
   976  				XAns: []float64{9.4, 15, -6.1, 3, 11.8, 7},
   977  				YAns: []float64{5.4, -2, 4, 2.9, 6, -3, -1, 10},
   978  			},
   979  			{
   980  				P: blas.DrotmParams{
   981  					Flag: blas.OffDiagonal,
   982  					H:    [4]float64{1, 0.1, -0.1, 1},
   983  				},
   984  				XAns: []float64{10.4, 15, -6.7, 3, 13.2, 7},
   985  				YAns: []float64{9.4, -2, 4, 6.4, 6, -3, -3, 10},
   986  			},
   987  			{
   988  				P: blas.DrotmParams{
   989  					Flag: blas.Diagonal,
   990  					H:    [4]float64{0.5, -1, 1, 0.7},
   991  				},
   992  				XAns: []float64{1, 15, 4, 3, 15, 7},
   993  				YAns: []float64{-8.4, -2, 4, 10.9, 6, -3, -12.8, 10},
   994  			},
   995  		},
   996  	},
   997  	{
   998  		Name:  "ZeroN",
   999  		X:     []float64{10, 15, -6, 3, 14, 7},
  1000  		Y:     []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1001  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
  1002  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
  1003  		Incx:  -2,
  1004  		Incy:  3,
  1005  		N:     0,
  1006  		Panic: false,
  1007  		DaxpyCases: []DaxpyCase{
  1008  			{
  1009  				Alpha: 2,
  1010  				Ans:   []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1011  			},
  1012  		},
  1013  		DswapAns: DTwoVecAnswer{
  1014  			X: []float64{10, 15, -6, 3, 14, 7},
  1015  			Y: []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1016  		},
  1017  		DcopyAns: DTwoVecAnswer{
  1018  			X: []float64{10, 15, -6, 3, 14, 7},
  1019  			Y: []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1020  		},
  1021  		DrotCases: []DrotCase{
  1022  			{
  1023  				C:    math.Cos(25 * math.Pi / 180),
  1024  				S:    math.Sin(25 * math.Pi / 180),
  1025  				XAns: []float64{10, 15, -6, 3, 14, 7},
  1026  				YAns: []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1027  			},
  1028  		},
  1029  		DrotmCases: []DrotmCase{
  1030  			{
  1031  				P: blas.DrotmParams{
  1032  					Flag: blas.Rescaling,
  1033  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
  1034  				},
  1035  				XAns: []float64{10, 15, -6, 3, 14, 7},
  1036  				YAns: []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1037  			},
  1038  		},
  1039  	},
  1040  	{
  1041  		Name:  "NegativeN",
  1042  		X:     []float64{10, 15, -6, 3, 14, 7},
  1043  		Y:     []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1044  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
  1045  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
  1046  		Incx:  -2,
  1047  		Incy:  3,
  1048  		N:     -3,
  1049  		Panic: true,
  1050  		DaxpyCases: []DaxpyCase{
  1051  			{
  1052  				Alpha: 2,
  1053  				Ans:   []float64{36, -2, 4, -5, 6, -3, 16, 10},
  1054  			},
  1055  		},
  1056  		DrotCases: []DrotCase{
  1057  			{
  1058  				C:    math.Cos(25 * math.Pi / 180),
  1059  				S:    math.Sin(25 * math.Pi / 180),
  1060  				XAns: []float64{10, 15, -6, 3, 14, 7},
  1061  				YAns: []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1062  			},
  1063  		},
  1064  		DrotmCases: []DrotmCase{
  1065  			{
  1066  				P: blas.DrotmParams{
  1067  					Flag: blas.Rescaling,
  1068  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
  1069  				},
  1070  				XAns: []float64{8.2, 13.7, -5.8, 2, 12, 6.6},
  1071  				YAns: []float64{5, 0.5, 1.4, 3.8, 4.4, -0.8},
  1072  			},
  1073  		},
  1074  	},
  1075  	{
  1076  		Name:  "ZeroIncX",
  1077  		X:     []float64{10, 15, -6, 3, 14, 7},
  1078  		Y:     []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1079  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
  1080  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
  1081  		Incx:  0,
  1082  		Incy:  3,
  1083  		N:     2,
  1084  		Panic: true,
  1085  		DaxpyCases: []DaxpyCase{
  1086  			{
  1087  				Alpha: 2,
  1088  				Ans:   []float64{36, -2, 4, -5, 6, -3, 16, 10},
  1089  			},
  1090  		},
  1091  		DrotCases: []DrotCase{
  1092  			{
  1093  				C:    math.Cos(25 * math.Pi / 180),
  1094  				S:    math.Sin(25 * math.Pi / 180),
  1095  				XAns: []float64{10, 15, -6, 3, 14, 7},
  1096  				YAns: []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1097  			},
  1098  		},
  1099  		DrotmCases: []DrotmCase{
  1100  			{
  1101  				P: blas.DrotmParams{
  1102  					Flag: blas.Rescaling,
  1103  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
  1104  				},
  1105  				XAns: []float64{8.2, 13.7, -5.8, 2, 12, 6.6},
  1106  				YAns: []float64{5, 0.5, 1.4, 3.8, 4.4, -0.8},
  1107  			},
  1108  		},
  1109  	},
  1110  	{
  1111  		Name:  "ZeroIncY",
  1112  		X:     []float64{10, 15, -6, 3, 14, 7},
  1113  		Y:     []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1114  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
  1115  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
  1116  		Incx:  1,
  1117  		Incy:  0,
  1118  		N:     2,
  1119  		Panic: true,
  1120  		DaxpyCases: []DaxpyCase{
  1121  			{
  1122  				Alpha: 2,
  1123  				Ans:   []float64{36, -2, 4, -5, 6, -3, 16, 10},
  1124  			},
  1125  		},
  1126  		DrotCases: []DrotCase{
  1127  			{
  1128  				C:    math.Cos(25 * math.Pi / 180),
  1129  				S:    math.Sin(25 * math.Pi / 180),
  1130  				XAns: []float64{10, 15, -6, 3, 14, 7},
  1131  				YAns: []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1132  			},
  1133  		},
  1134  		DrotmCases: []DrotmCase{
  1135  			{
  1136  				P: blas.DrotmParams{
  1137  					Flag: blas.Rescaling,
  1138  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
  1139  				},
  1140  				XAns: []float64{8.2, 13.7, -5.8, 2, 12, 6.6},
  1141  				YAns: []float64{5, 0.5, 1.4, 3.8, 4.4, -0.8},
  1142  			},
  1143  		},
  1144  	},
  1145  	{
  1146  		Name:  "OutOfBoundsX",
  1147  		X:     []float64{10, 15, -6, 3, 14, 7},
  1148  		Y:     []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1149  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
  1150  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
  1151  		Incx:  8,
  1152  		Incy:  2,
  1153  		N:     2,
  1154  		Panic: true,
  1155  		DaxpyCases: []DaxpyCase{
  1156  			{
  1157  				Alpha: 2,
  1158  				Ans:   []float64{36, -2, 4, -5, 6, -3, 16, 10},
  1159  			},
  1160  		},
  1161  		DrotCases: []DrotCase{
  1162  			{
  1163  				C:    math.Cos(25 * math.Pi / 180),
  1164  				S:    math.Sin(25 * math.Pi / 180),
  1165  				XAns: []float64{10, 15, -6, 3, 14, 7},
  1166  				YAns: []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1167  			},
  1168  		},
  1169  		DrotmCases: []DrotmCase{
  1170  			{
  1171  				P: blas.DrotmParams{
  1172  					Flag: blas.Rescaling,
  1173  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
  1174  				},
  1175  				XAns: []float64{8.2, 13.7, -5.8, 2, 12, 6.6},
  1176  				YAns: []float64{5, 0.5, 1.4, 3.8, 4.4, -0.8},
  1177  			},
  1178  		},
  1179  	},
  1180  	{
  1181  		Name:  "OutOfBoundsY",
  1182  		X:     []float64{10, 15, -6, 3, 14, 7},
  1183  		Y:     []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1184  		XTmp:  []float64{0, 0, 0, 0, 0, 0},
  1185  		YTmp:  []float64{0, 0, 0, 0, 0, 0, 0, 0},
  1186  		Incx:  2,
  1187  		Incy:  8,
  1188  		N:     2,
  1189  		Panic: true,
  1190  		DaxpyCases: []DaxpyCase{
  1191  			{
  1192  				Alpha: 2,
  1193  				Ans:   []float64{36, -2, 4, -5, 6, -3, 16, 10},
  1194  			},
  1195  		},
  1196  		DrotCases: []DrotCase{
  1197  			{
  1198  				C:    math.Cos(25 * math.Pi / 180),
  1199  				S:    math.Sin(25 * math.Pi / 180),
  1200  				XAns: []float64{10, 15, -6, 3, 14, 7},
  1201  				YAns: []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1202  			},
  1203  		},
  1204  		DrotmCases: []DrotmCase{
  1205  			{
  1206  				P: blas.DrotmParams{
  1207  					Flag: blas.Rescaling,
  1208  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
  1209  				},
  1210  				XAns: []float64{10, 15, -6, 3, 14, 7},
  1211  				YAns: []float64{8, -2, 4, 7, 6, -3, -4, 10},
  1212  			},
  1213  		},
  1214  	},
  1215  	{
  1216  		Name:  "Empty",
  1217  		X:     []float64{},
  1218  		Y:     []float64{},
  1219  		Incx:  1,
  1220  		Incy:  1,
  1221  		N:     0,
  1222  		Panic: false,
  1223  		DaxpyCases: []DaxpyCase{
  1224  			{
  1225  				Alpha: 2,
  1226  				Ans:   []float64{},
  1227  			},
  1228  		},
  1229  		DrotCases: []DrotCase{
  1230  			{
  1231  				C:    math.Cos(25 * math.Pi / 180),
  1232  				S:    math.Sin(25 * math.Pi / 180),
  1233  				XAns: []float64{},
  1234  				YAns: []float64{},
  1235  			},
  1236  		},
  1237  		DrotmCases: []DrotmCase{
  1238  			{
  1239  				P: blas.DrotmParams{
  1240  					Flag: blas.Rescaling,
  1241  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
  1242  				},
  1243  				XAns: []float64{},
  1244  				YAns: []float64{},
  1245  			},
  1246  		},
  1247  	},
  1248  	{
  1249  		Name:  "EmptyZeroIncX",
  1250  		X:     []float64{},
  1251  		Y:     []float64{},
  1252  		Incx:  0,
  1253  		Incy:  1,
  1254  		N:     0,
  1255  		Panic: true,
  1256  		DaxpyCases: []DaxpyCase{
  1257  			{
  1258  				Alpha: 2,
  1259  				Ans:   []float64{},
  1260  			},
  1261  		},
  1262  		DrotCases: []DrotCase{
  1263  			{
  1264  				C:    math.Cos(25 * math.Pi / 180),
  1265  				S:    math.Sin(25 * math.Pi / 180),
  1266  				XAns: []float64{},
  1267  				YAns: []float64{},
  1268  			},
  1269  		},
  1270  		DrotmCases: []DrotmCase{
  1271  			{
  1272  				P: blas.DrotmParams{
  1273  					Flag: blas.Rescaling,
  1274  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
  1275  				},
  1276  				XAns: []float64{},
  1277  				YAns: []float64{},
  1278  			},
  1279  		},
  1280  	},
  1281  	{
  1282  		Name:  "EmptyZeroIncY",
  1283  		X:     []float64{},
  1284  		Y:     []float64{},
  1285  		Incx:  1,
  1286  		Incy:  0,
  1287  		N:     0,
  1288  		Panic: true,
  1289  		DaxpyCases: []DaxpyCase{
  1290  			{
  1291  				Alpha: 2,
  1292  				Ans:   []float64{},
  1293  			},
  1294  		},
  1295  		DrotCases: []DrotCase{
  1296  			{
  1297  				C:    math.Cos(25 * math.Pi / 180),
  1298  				S:    math.Sin(25 * math.Pi / 180),
  1299  				XAns: []float64{},
  1300  				YAns: []float64{},
  1301  			},
  1302  		},
  1303  		DrotmCases: []DrotmCase{
  1304  			{
  1305  				P: blas.DrotmParams{
  1306  					Flag: blas.Rescaling,
  1307  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
  1308  				},
  1309  				XAns: []float64{},
  1310  				YAns: []float64{},
  1311  			},
  1312  		},
  1313  	},
  1314  	{
  1315  		Name:  "EmptyReverse",
  1316  		X:     []float64{},
  1317  		Y:     []float64{},
  1318  		Incx:  -1,
  1319  		Incy:  -1,
  1320  		N:     0,
  1321  		Panic: false,
  1322  		DaxpyCases: []DaxpyCase{
  1323  			{
  1324  				Alpha: 2,
  1325  				Ans:   []float64{},
  1326  			},
  1327  		},
  1328  		DrotCases: []DrotCase{
  1329  			{
  1330  				C:    math.Cos(25 * math.Pi / 180),
  1331  				S:    math.Sin(25 * math.Pi / 180),
  1332  				XAns: []float64{},
  1333  				YAns: []float64{},
  1334  			},
  1335  		},
  1336  		DrotmCases: []DrotmCase{
  1337  			{
  1338  				P: blas.DrotmParams{
  1339  					Flag: blas.Rescaling,
  1340  					H:    [4]float64{0.9, 0.1, -0.1, 0.5},
  1341  				},
  1342  				XAns: []float64{},
  1343  				YAns: []float64{},
  1344  			},
  1345  		},
  1346  	},
  1347  }
  1348  
  1349  type Ddotter interface {
  1350  	Ddot(n int, x []float64, incX int, y []float64, incY int) float64
  1351  }
  1352  
  1353  func DdotTest(t *testing.T, d Ddotter) {
  1354  	ddot := d.Ddot
  1355  	for _, c := range DoubleTwoVectorCases {
  1356  		dCopyTwoTmp(c.X, c.XTmp, c.Y, c.YTmp)
  1357  		if c.Panic {
  1358  			f := func() { ddot(c.N, c.XTmp, c.Incx, c.YTmp, c.Incy) }
  1359  			testpanics(f, c.Name, t)
  1360  			continue
  1361  		}
  1362  		dot := ddot(c.N, c.XTmp, c.Incx, c.YTmp, c.Incy)
  1363  		if !dTolEqual(dot, c.DdotAns) {
  1364  			t.Errorf("ddot: mismatch %v: expected %v, found %v", c.Name, c.DdotAns, dot)
  1365  		}
  1366  	}
  1367  
  1368  	// check it works for 16-byte unaligned slices
  1369  	x := []float64{1, 1, 1, 1, 1}
  1370  	if n := ddot(4, x[:4], 1, x[1:], 1); n != 4 {
  1371  		t.Errorf("ddot: mismatch Unaligned: expected %v, found %v", 4, n)
  1372  	}
  1373  	if n := ddot(2, x[:4], 2, x[1:], 2); n != 2 {
  1374  		t.Errorf("ddot: mismatch Unaligned: expected %v, found %v", 2, n)
  1375  	}
  1376  	if n := ddot(2, x[:4], 3, x[1:], 3); n != 2 {
  1377  		t.Errorf("ddot: mismatch Unaligned: expected %v, found %v", 2, n)
  1378  	}
  1379  }
  1380  
  1381  type Dnrm2er interface {
  1382  	Dnrm2(n int, x []float64, incX int) float64
  1383  }
  1384  
  1385  func Dnrm2Test(t *testing.T, blasser Dnrm2er) {
  1386  	dnrm2 := blasser.Dnrm2
  1387  	for _, c := range DoubleOneVectorCases {
  1388  		if c.Panic {
  1389  			f := func() { dnrm2(c.N, c.X, c.Incx) }
  1390  			testpanics(f, c.Name, t)
  1391  			continue
  1392  		}
  1393  		v := dnrm2(c.N, c.X, c.Incx)
  1394  		if !dTolEqual(v, c.Dnrm2) {
  1395  			t.Errorf("dnrm2: mismatch %v: expected %v, found %v", c.Name, c.Dnrm2, v)
  1396  		}
  1397  	}
  1398  }
  1399  
  1400  type Dasumer interface {
  1401  	Dasum(n int, x []float64, incX int) float64
  1402  }
  1403  
  1404  func DasumTest(t *testing.T, blasser Dasumer) {
  1405  	dasum := blasser.Dasum
  1406  	for _, c := range DoubleOneVectorCases {
  1407  		if c.Panic {
  1408  			f := func() { dasum(c.N, c.X, c.Incx) }
  1409  			testpanics(f, c.Name, t)
  1410  			continue
  1411  		}
  1412  		v := dasum(c.N, c.X, c.Incx)
  1413  		if !dTolEqual(v, c.Dasum) {
  1414  			t.Errorf("dasum: mismatch %v: expected %v, found %v", c.Name, c.Dasum, v)
  1415  		}
  1416  	}
  1417  }
  1418  
  1419  type Idamaxer interface {
  1420  	Idamax(n int, x []float64, incX int) int
  1421  }
  1422  
  1423  func IdamaxTest(t *testing.T, blasser Idamaxer) {
  1424  	idamax := blasser.Idamax
  1425  	for _, c := range DoubleOneVectorCases {
  1426  		if c.Panic {
  1427  			f := func() { idamax(c.N, c.X, c.Incx) }
  1428  			testpanics(f, c.Name, t)
  1429  			continue
  1430  		}
  1431  		v := idamax(c.N, c.X, c.Incx)
  1432  		if v != c.Idamax {
  1433  			s := fmt.Sprintf("idamax: mismatch %v: expected %v, found %v", c.Name, c.Idamax, v)
  1434  			if floats.HasNaN(c.X) {
  1435  				t.Log(s)
  1436  			} else {
  1437  				t.Errorf(s)
  1438  			}
  1439  		}
  1440  	}
  1441  }
  1442  
  1443  type Dswapper interface {
  1444  	Dswap(n int, x []float64, incX int, y []float64, incY int)
  1445  }
  1446  
  1447  func DswapTest(t *testing.T, d Dswapper) {
  1448  	dswap := d.Dswap
  1449  	for _, c := range DoubleTwoVectorCases {
  1450  		dCopyTwoTmp(c.X, c.XTmp, c.Y, c.YTmp)
  1451  		if c.Panic {
  1452  			f := func() { dswap(c.N, c.XTmp, c.Incx, c.YTmp, c.Incy) }
  1453  			testpanics(f, c.Name, t)
  1454  			continue
  1455  		}
  1456  		dswap(c.N, c.XTmp, c.Incx, c.YTmp, c.Incy)
  1457  		if !dSliceTolEqual(c.XTmp, c.DswapAns.X) {
  1458  			t.Errorf("dswap: x mismatch %v: expected %v, found %v", c.Name, c.DswapAns.X, c.XTmp)
  1459  		}
  1460  		if !dSliceTolEqual(c.YTmp, c.DswapAns.Y) {
  1461  			t.Errorf("dswap: y mismatch %v: expected %v, found %v", c.Name, c.DswapAns.Y, c.YTmp)
  1462  		}
  1463  	}
  1464  }
  1465  
  1466  type Dcopier interface {
  1467  	Dcopy(n int, x []float64, incX int, y []float64, incY int)
  1468  }
  1469  
  1470  func DcopyTest(t *testing.T, d Dcopier) {
  1471  	dcopy := d.Dcopy
  1472  	for _, c := range DoubleTwoVectorCases {
  1473  		dCopyTwoTmp(c.X, c.XTmp, c.Y, c.YTmp)
  1474  		if c.Panic {
  1475  			f := func() { dcopy(c.N, c.XTmp, c.Incx, c.YTmp, c.Incy) }
  1476  			testpanics(f, c.Name, t)
  1477  			continue
  1478  		}
  1479  		dcopy(c.N, c.XTmp, c.Incx, c.YTmp, c.Incy)
  1480  		if !dSliceTolEqual(c.XTmp, c.DcopyAns.X) {
  1481  			t.Errorf("dswap: x mismatch %v: expected %v, found %v", c.Name, c.DcopyAns.X, c.XTmp)
  1482  		}
  1483  		if !dSliceTolEqual(c.YTmp, c.DcopyAns.Y) {
  1484  			t.Errorf("dswap: y mismatch %v: expected %v, found %v", c.Name, c.DcopyAns.Y, c.YTmp)
  1485  		}
  1486  	}
  1487  }
  1488  
  1489  type Daxpyer interface {
  1490  	Daxpy(n int, alpha float64, x []float64, incX int, y []float64, incY int)
  1491  }
  1492  
  1493  func DaxpyTest(t *testing.T, d Daxpyer) {
  1494  	daxpy := d.Daxpy
  1495  	for _, c := range DoubleTwoVectorCases {
  1496  		for _, kind := range c.DaxpyCases {
  1497  			dCopyTwoTmp(c.X, c.XTmp, c.Y, c.YTmp)
  1498  			if c.Panic {
  1499  				f := func() { daxpy(c.N, kind.Alpha, c.XTmp, c.Incx, c.YTmp, c.Incy) }
  1500  				testpanics(f, c.Name, t)
  1501  				continue
  1502  			}
  1503  			daxpy(c.N, kind.Alpha, c.XTmp, c.Incx, c.YTmp, c.Incy)
  1504  			if !dSliceTolEqual(c.YTmp, kind.Ans) {
  1505  				t.Errorf("daxpy: mismatch %v: expected %v, found %v", c.Name, kind.Ans, c.YTmp)
  1506  			}
  1507  		}
  1508  	}
  1509  }
  1510  
  1511  type DrotgTestStruct struct {
  1512  	Name       string
  1513  	A, B       float64
  1514  	C, S, R, Z float64
  1515  }
  1516  
  1517  var DrotgTests = []DrotgTestStruct{
  1518  	{
  1519  		Name: "ZeroAB",
  1520  		C:    1,
  1521  	},
  1522  	{
  1523  		Name: "PosA_ZeroB",
  1524  		A:    0.5,
  1525  		C:    1,
  1526  		R:    0.5,
  1527  	},
  1528  	{
  1529  		Name: "NegA_ZeroB",
  1530  		A:    -4.6,
  1531  		C:    1,
  1532  		R:    -4.6,
  1533  	},
  1534  	{
  1535  		Name: "ZeroA_PosB",
  1536  		B:    3,
  1537  		S:    1,
  1538  		R:    3,
  1539  		Z:    1,
  1540  	},
  1541  	{
  1542  		Name: "ZeroA_NegB",
  1543  		B:    -0.3,
  1544  		S:    1,
  1545  		R:    -0.3,
  1546  		Z:    1,
  1547  	},
  1548  	{
  1549  		Name: "PosA_PosB_AGTB",
  1550  		A:    5,
  1551  		B:    0.3,
  1552  		C:    0.99820484546577868593549038000,
  1553  		S:    0.05989229072794672115612942280,
  1554  		R:    5.00899191454727744602429072688,
  1555  		Z:    0.05989229072794672115612942280,
  1556  	},
  1557  	{
  1558  		Name: "PosA_PosB_ALTB",
  1559  		A:    3,
  1560  		B:    4,
  1561  		C:    3.0 / 5,
  1562  		S:    4.0 / 5,
  1563  		R:    5,
  1564  		Z:    5.0 / 3.0,
  1565  	},
  1566  
  1567  	{
  1568  		Name: "PosA_NegB_AGTB",
  1569  		A:    2.6,
  1570  		B:    -0.9,
  1571  		C:    0.94498607344025815971847507095,
  1572  		S:    -0.32711056388316628605639521686,
  1573  		R:    2.751363298439520872718790879655,
  1574  		Z:    -0.3271105638831662860563952168,
  1575  	},
  1576  	{
  1577  		Name: "PosA_NegB_ALTB",
  1578  		A:    2.6,
  1579  		B:    -2.9,
  1580  		C:    -0.6675450157520258540548049558,
  1581  		S:    0.7445694406464903756765132200,
  1582  		R:    -3.8948684188300893100043812234,
  1583  		Z:    1 / -0.6675450157520258540548049558,
  1584  	},
  1585  	{
  1586  		Name: "NegA_PosB_AGTB",
  1587  		A:    -11.4,
  1588  		B:    10.3,
  1589  		C:    0.7419981952497362418487847947,
  1590  		S:    -0.6704018781642353764072353847,
  1591  		R:    -15.363918770938617534070671122,
  1592  		Z:    -0.6704018781642353764072353847,
  1593  	},
  1594  	{
  1595  		Name: "NegA_PosB_ALTB",
  1596  		A:    -1.4,
  1597  		B:    10.3,
  1598  		C:    -0.1346838895922121112404717523,
  1599  		S:    0.9908886162855605326977564640,
  1600  		R:    10.394710193170370442523552032,
  1601  		Z:    1 / -0.1346838895922121112404717523,
  1602  	},
  1603  	{
  1604  		Name: "NegA_NegB_AGTB",
  1605  		A:    -11.4,
  1606  		B:    10.3,
  1607  		C:    0.7419981952497362418487847947,
  1608  		S:    -0.6704018781642353764072353847,
  1609  		R:    -15.363918770938617534070671122,
  1610  		Z:    -0.6704018781642353764072353847,
  1611  	},
  1612  	{
  1613  		Name: "NegA_NegB_ALTB",
  1614  		A:    -1.4,
  1615  		B:    -10.3,
  1616  		C:    0.1346838895922121112404717523,
  1617  		S:    0.9908886162855605326977564640,
  1618  		R:    -10.394710193170370442523552032,
  1619  		Z:    1 / 0.1346838895922121112404717523,
  1620  	},
  1621  }
  1622  
  1623  type Drotger interface {
  1624  	Drotg(a, b float64) (c, s, r, z float64)
  1625  }
  1626  
  1627  func DrotgTest(t *testing.T, d Drotger, skipExtreme bool) {
  1628  	drotg := d.Drotg
  1629  	for _, test := range DrotgTests {
  1630  		c, s, r, z := drotg(test.A, test.B)
  1631  		if !dTolEqual(c, test.C) {
  1632  			t.Errorf("drotg: c mismatch %v: expected %v, found %v", test.Name, test.C, c)
  1633  		}
  1634  		if !dTolEqual(s, test.S) {
  1635  			t.Errorf("drotg: s mismatch %v: expected %v, found %v", test.Name, test.S, s)
  1636  		}
  1637  		if !dTolEqual(r, test.R) {
  1638  			t.Errorf("drotg: r mismatch %v: expected %v, found %v", test.Name, test.R, r)
  1639  		}
  1640  		if !dTolEqual(z, test.Z) {
  1641  			t.Errorf("drotg: z mismatch %v: expected %v, found %v", test.Name, test.Z, z)
  1642  		}
  1643  	}
  1644  
  1645  	const (
  1646  		ulp    = 0x1p-52
  1647  		safmin = 0x1p-1022
  1648  		safmax = 1 / safmin
  1649  		tol    = 20 * ulp
  1650  	)
  1651  	values := []float64{
  1652  		-1 / ulp,
  1653  		-1,
  1654  		-1.0 / 3,
  1655  		-ulp,
  1656  		0,
  1657  		ulp,
  1658  		1.0 / 3,
  1659  		1,
  1660  		1 / ulp,
  1661  		math.Inf(-1),
  1662  		math.Inf(1),
  1663  		math.NaN(),
  1664  	}
  1665  	if !skipExtreme {
  1666  		values = append(values, -safmax, -safmin, safmin, safmax)
  1667  	}
  1668  	for _, f := range values {
  1669  		for _, g := range values {
  1670  			name := fmt.Sprintf("Case f=%v,g=%v", f, g)
  1671  
  1672  			// Generate a plane rotation so that
  1673  			//  [ cs sn] * [f] = [r]
  1674  			//  [-sn cs]   [g] = [0]
  1675  			// where cs*cs + sn*sn = 1.
  1676  			cs, sn, r, _ := drotg(f, g)
  1677  
  1678  			switch {
  1679  			case math.IsNaN(f) || math.IsNaN(g):
  1680  				if !math.IsNaN(r) {
  1681  					t.Errorf("%v: unexpected r=%v; want NaN", name, r)
  1682  				}
  1683  			case math.IsInf(f, 0) || math.IsInf(g, 0):
  1684  				if !math.IsNaN(r) && !math.IsInf(r, 0) {
  1685  					t.Errorf("%v: unexpected r=%v; want NaN or Inf", name, r)
  1686  				}
  1687  			default:
  1688  				d := math.Max(math.Abs(f), math.Abs(g))
  1689  				d = math.Min(math.Max(safmin, d), safmax)
  1690  				fs := f / d
  1691  				gs := g / d
  1692  				rs := r / d
  1693  
  1694  				// Check that cs*f + sn*g = r.
  1695  				rnorm := math.Abs(rs)
  1696  				if rnorm == 0 {
  1697  					rnorm = math.Max(math.Abs(fs), math.Abs(gs))
  1698  					if rnorm == 0 {
  1699  						rnorm = 1
  1700  					}
  1701  				}
  1702  				resid := math.Abs(rs-(cs*fs+sn*gs)) / rnorm
  1703  				if resid > tol {
  1704  					t.Errorf("%v: cs*f + sn*g != r; resid=%v", name, resid)
  1705  				}
  1706  
  1707  				// Check that -sn*f + cs*g = 0.
  1708  				resid = math.Abs(-sn*fs + cs*gs)
  1709  				if resid > tol {
  1710  					t.Errorf("%v: -sn*f + cs*g != 0; resid=%v", name, resid)
  1711  				}
  1712  
  1713  				// Check that cs*cs + sn*sn = 1.
  1714  				resid = math.Abs(1 - (cs*cs + sn*sn))
  1715  				if resid > tol {
  1716  					t.Errorf("%v: cs*cs + sn*sn != 1; resid=%v", name, resid)
  1717  				}
  1718  
  1719  				// Check that cs is non-negative.
  1720  				if math.Abs(f) > math.Abs(g) {
  1721  					if cs < 0 {
  1722  						t.Errorf("%v: cs is negative; cs=%v", name, cs)
  1723  					}
  1724  				} else {
  1725  					if cs*math.Copysign(1, f)*math.Copysign(1, g) < 0 {
  1726  						t.Errorf("%v: sign of cs doesn't match sign of f and g; cs=%v, sign(f)=%v, sign(g)=%v",
  1727  							name, cs, math.Copysign(1, f), math.Copysign(1, g))
  1728  					}
  1729  				}
  1730  			}
  1731  		}
  1732  	}
  1733  }
  1734  
  1735  type Drotmger interface {
  1736  	Drotmg(d1, d2, x1, y1 float64) (p blas.DrotmParams, rd1, rd2, rx1 float64)
  1737  	Drotmer
  1738  }
  1739  
  1740  func DrotmgTest(t *testing.T, d Drotmger) {
  1741  	const tol = 1e-14
  1742  
  1743  	var tests = []struct {
  1744  		name                   string
  1745  		d1, d2, x1, y1         float64
  1746  		d1Want, d2Want, x1Want float64
  1747  		pWant                  blas.DrotmParams
  1748  	}{
  1749  		{
  1750  			name:   "NegD1",
  1751  			d1:     -4,
  1752  			d2:     6,
  1753  			x1:     8,
  1754  			y1:     -4,
  1755  			d1Want: 0,
  1756  			d2Want: 0,
  1757  			x1Want: 0,
  1758  			pWant: blas.DrotmParams{
  1759  				Flag: blas.Rescaling,
  1760  				H:    [4]float64{0, 0, 0, 0},
  1761  			},
  1762  		},
  1763  		{
  1764  			name:   "ZeroD2",
  1765  			d1:     4,
  1766  			d2:     0,
  1767  			x1:     8,
  1768  			y1:     -5,
  1769  			d1Want: 4,
  1770  			d2Want: 0,
  1771  			x1Want: 8,
  1772  			pWant: blas.DrotmParams{
  1773  				Flag: blas.Identity,
  1774  				H:    [4]float64{0, 0, 0, 0},
  1775  			},
  1776  		},
  1777  		{
  1778  			name:   "ZeroY1",
  1779  			d1:     4,
  1780  			d2:     -6,
  1781  			x1:     8,
  1782  			y1:     0,
  1783  			d1Want: 4,
  1784  			d2Want: -6,
  1785  			x1Want: 8,
  1786  			pWant: blas.DrotmParams{
  1787  				Flag: blas.Identity,
  1788  				H:    [4]float64{0, 0, 0, 0},
  1789  			},
  1790  		},
  1791  		{
  1792  			name:   "NegQ2_and_AQ1_LT_AQ2",
  1793  			d1:     8,
  1794  			d2:     -6,
  1795  			x1:     4,
  1796  			y1:     8,
  1797  			d1Want: 0,
  1798  			d2Want: 0,
  1799  			x1Want: 0,
  1800  			pWant: blas.DrotmParams{
  1801  				Flag: blas.Rescaling,
  1802  				H:    [4]float64{0, 0, 0, 0},
  1803  			},
  1804  		},
  1805  		{
  1806  			name:   "ZeroD1",
  1807  			d1:     0,
  1808  			d2:     2,
  1809  			x1:     8,
  1810  			y1:     4,
  1811  			d1Want: 2,
  1812  			d2Want: 0,
  1813  			x1Want: 4,
  1814  			pWant: blas.DrotmParams{
  1815  				Flag: blas.Diagonal,
  1816  				H:    [4]float64{0, 0, 0, 0},
  1817  			},
  1818  		},
  1819  		{
  1820  			name:   "AbsQ1_GT_AbsQU__D2_Pos",
  1821  			d1:     2,
  1822  			d2:     3,
  1823  			x1:     8,
  1824  			y1:     5,
  1825  			d1Want: 1.2610837438423645,
  1826  			d2Want: 1.8916256157635467,
  1827  			x1Want: 12.6875,
  1828  			pWant: blas.DrotmParams{
  1829  				Flag: blas.OffDiagonal,
  1830  				H:    [4]float64{0, -0.625, 0.9375, 0},
  1831  			},
  1832  		},
  1833  		{
  1834  			name:   "AbsQ1_GT_AbsQU__D2_Neg",
  1835  			d1:     2,
  1836  			d2:     -3,
  1837  			x1:     8,
  1838  			y1:     5,
  1839  			d1Want: 4.830188679245283,
  1840  			d2Want: -7.245283018867925,
  1841  			x1Want: 3.3125,
  1842  			pWant: blas.DrotmParams{
  1843  				Flag: blas.OffDiagonal,
  1844  				H:    [4]float64{0, -0.625, -0.9375, 0},
  1845  			},
  1846  		},
  1847  		{
  1848  			name:   "AbsQ1_LT_AbsQU__D2_Pos",
  1849  			d1:     2,
  1850  			d2:     3,
  1851  			x1:     5,
  1852  			y1:     8,
  1853  			d1Want: 2.3801652892561984,
  1854  			d2Want: 1.586776859504132,
  1855  			x1Want: 121.0 / 12,
  1856  			pWant: blas.DrotmParams{
  1857  				Flag: blas.Diagonal,
  1858  				H:    [4]float64{5.0 / 12, 0, 0, 0.625},
  1859  			},
  1860  		},
  1861  		{
  1862  			name:   "D1=D2_X1=X2",
  1863  			d1:     2,
  1864  			d2:     2,
  1865  			x1:     8,
  1866  			y1:     8,
  1867  			d1Want: 1,
  1868  			d2Want: 1,
  1869  			x1Want: 16,
  1870  			pWant: blas.DrotmParams{
  1871  				Flag: blas.Diagonal,
  1872  				H:    [4]float64{1, 0, 0, 1},
  1873  			},
  1874  		},
  1875  		{
  1876  			name:   "RD1_Big_RD2_Big_Flag_0",
  1877  			d1:     1600000000,
  1878  			d2:     800000000,
  1879  			x1:     8,
  1880  			y1:     7,
  1881  			d1Want: 68.96627824858757,
  1882  			d2Want: 34.483139124293785,
  1883  			x1Want: 45312,
  1884  			pWant: blas.DrotmParams{
  1885  				Flag: blas.Rescaling,
  1886  				H:    [4]float64{4096, -3584, 1792, 4096},
  1887  			},
  1888  		},
  1889  		{
  1890  			name:   "RD1_Big_RD2_Big_Flag_1",
  1891  			d1:     800000000,
  1892  			d2:     1600000000,
  1893  			x1:     8,
  1894  			y1:     7,
  1895  			d1Want: 57.6914092640818,
  1896  			d2Want: 28.8457046320409,
  1897  			x1Want: 47396.57142857142,
  1898  			pWant: blas.DrotmParams{
  1899  				Flag: blas.Rescaling,
  1900  				H:    [4]float64{2340.5714285714284, -4096, 4096, 4681.142857142857},
  1901  			},
  1902  		},
  1903  		{
  1904  			name:   "RD1_Big_RD2_Med_Flag_0",
  1905  			d1:     20000000,
  1906  			d2:     2,
  1907  			x1:     8,
  1908  			y1:     8,
  1909  			d1Want: 1.1920927762985347,
  1910  			d2Want: 1.9999998000000199,
  1911  			x1Want: 32768.0032768,
  1912  			pWant: blas.DrotmParams{
  1913  				Flag: blas.Rescaling,
  1914  				H:    [4]float64{4096, -1, 0.0004096, 1},
  1915  			},
  1916  		},
  1917  		{
  1918  			name:   "RD1_Big_RD2_Med_Flag_1",
  1919  			d1:     2,
  1920  			d2:     20000000000,
  1921  			x1:     8,
  1922  			y1:     80000000000,
  1923  			d1Want: 1192.0928955078125,
  1924  			d2Want: 2,
  1925  			x1Want: 3.2768e+14,
  1926  			pWant: blas.DrotmParams{
  1927  				Flag: blas.Rescaling,
  1928  				H:    [4]float64{4.096e-17, -1, 4096, 1e-10},
  1929  			},
  1930  		},
  1931  		{
  1932  			name:   "D1_Big_D2_Small_Flag_1",
  1933  			d1:     0.000000014,
  1934  			d2:     2000000000,
  1935  			x1:     0.000008,
  1936  			y1:     8000000,
  1937  			d1Want: 119.20928955078125,
  1938  			d2Want: 0.234881024,
  1939  			x1Want: 3.2768e+10,
  1940  			pWant: blas.DrotmParams{
  1941  				Flag: blas.Rescaling,
  1942  				H:    [4]float64{2.8671999999999997e-26, -0.000244140625, 4096, 2.44140625e-16},
  1943  			},
  1944  		},
  1945  		{
  1946  			name:   "RD1_Med_RD2_Big_Flag_0",
  1947  			d1:     2,
  1948  			d2:     20000000000,
  1949  			x1:     80000000,
  1950  			y1:     8,
  1951  			d1Want: 1.9998000199980002,
  1952  			d2Want: 1191.9736981379988,
  1953  			x1Want: 8.0008e+07,
  1954  			pWant: blas.DrotmParams{
  1955  				Flag: blas.Rescaling,
  1956  				H:    [4]float64{1, -0.0004096, 1000, 4096},
  1957  			},
  1958  		},
  1959  		{
  1960  			name:   "D1_Med_D2_Big_Flag_1",
  1961  			d1:     20000000000,
  1962  			d2:     0.4,
  1963  			x1:     80000000,
  1964  			y1:     80000000000000000,
  1965  			d1Want: 0.39999998000000103,
  1966  			d2Want: 1192.092835903171,
  1967  			x1Want: 8.0000004e+16,
  1968  			pWant: blas.DrotmParams{
  1969  				Flag: blas.Rescaling,
  1970  				H:    [4]float64{50, -4096, 1, 4.096e-06},
  1971  			},
  1972  		},
  1973  		{
  1974  			name:   "RD1_Med_RD2_Small_Flag_0",
  1975  			d1:     1.2,
  1976  			d2:     0.000000000045,
  1977  			x1:     2.7,
  1978  			y1:     8,
  1979  			d1Want: 1.1999999996049382,
  1980  			d2Want: 0.0007549747197514486,
  1981  			x1Want: 2.700000000888889,
  1982  			pWant: blas.DrotmParams{
  1983  				Flag: blas.Rescaling,
  1984  				H:    [4]float64{1, -0.0007233796296296296, 1.1111111111111111e-10, 0.000244140625},
  1985  			},
  1986  		},
  1987  		{
  1988  			name:   "RD1_Med_RD2_Small_Flag_1",
  1989  			d1:     1.2,
  1990  			d2:     0.000000000045,
  1991  			x1:     2.7,
  1992  			y1:     80000000000,
  1993  			d1Want: 0.0007549747199770676,
  1994  			d2Want: 1.19999999996355,
  1995  			x1Want: 1.9531250000593264e+07,
  1996  			pWant: blas.DrotmParams{
  1997  				Flag: blas.Rescaling,
  1998  				H:    [4]float64{0.0002197265625, -1, 0.000244140625, 3.375e-11},
  1999  			},
  2000  		},
  2001  		{
  2002  			name:   "D1_Small_D2_Big_Flag_1",
  2003  			d1:     120000000000000000,
  2004  			d2:     0.000000000012345,
  2005  			x1:     0.08,
  2006  			y1:     8000000000000,
  2007  			d1Want: 0.00010502490698765249,
  2008  			d2Want: 216.1836123957717,
  2009  			x1Want: 3.8516669198055897e+09,
  2010  			pWant: blas.DrotmParams{
  2011  				Flag: blas.Rescaling,
  2012  				H:    [4]float64{2.3731773997569866e+10, -1.6777216e+07, 0.000244140625, 1.6777216e-07},
  2013  			},
  2014  		},
  2015  		{
  2016  			name:   "RD1_Small_RD2_Med_Flag_0",
  2017  			d1:     0.0000000002,
  2018  			d2:     20,
  2019  			x1:     0.8,
  2020  			y1:     0.000000008,
  2021  			d1Want: 0.003355409645903541,
  2022  			d2Want: 19.99980000199998,
  2023  			x1Want: 0.000195314453125,
  2024  			pWant: blas.DrotmParams{
  2025  				Flag: blas.Rescaling,
  2026  				H:    [4]float64{0.000244140625, -1e-08, 0.24414062499999997, 1},
  2027  			},
  2028  		},
  2029  		{
  2030  			name:   "RD1_Small_RD2_Med_Flag_1",
  2031  			d1:     0.02,
  2032  			d2:     0.000000000004,
  2033  			x1:     0.008,
  2034  			y1:     8000000,
  2035  			d1Want: 6.710886366445568e-05,
  2036  			d2Want: 0.019999999900000003,
  2037  			x1Want: 1953.125009765625,
  2038  			pWant: blas.DrotmParams{
  2039  				Flag: blas.Rescaling,
  2040  				H:    [4]float64{0.0012207031250000002, -1, 0.000244140625, 1e-09},
  2041  			},
  2042  		},
  2043  		{
  2044  			// Values consistent with the low precision output posted at the  OpenBLAS issue.
  2045  			// See https://github.com/xianyi/OpenBLAS/issues/1452.
  2046  			name:   "OpenBLAS#1452",
  2047  			d1:     5.9e-8,
  2048  			d2:     5.960464e-8,
  2049  			x1:     1,
  2050  			y1:     150,
  2051  			d1Want: 0.9999559282289687,
  2052  			d2Want: 0.9898121986058326,
  2053  			x1Want: 0.03662270484346241,
  2054  			pWant: blas.DrotmParams{
  2055  				Flag: blas.Rescaling,
  2056  				H:    [4]float64{1.6110934624105326e-06, -0.000244140625, 0.000244140625, 1.6276041666666668e-06},
  2057  			},
  2058  		},
  2059  
  2060  		// Test cases with values taken from BLAS/TESTING/dblat1.f in the reference.
  2061  		{
  2062  			name:   "netlib/BLAS/TESTING#1",
  2063  			d1:     0.1,
  2064  			d2:     0.3,
  2065  			x1:     1.2,
  2066  			y1:     0.2,
  2067  			d1Want: 12 / 130.0,
  2068  			d2Want: 36 / 130.0,
  2069  			x1Want: 1.3,
  2070  			pWant: blas.DrotmParams{
  2071  				Flag: blas.OffDiagonal,
  2072  				H:    [4]float64{0, -1 / 6.0, 0.5, 0},
  2073  			},
  2074  		},
  2075  		{
  2076  			name:   "netlib/BLAS/TESTING#2",
  2077  			d1:     0.7,
  2078  			d2:     0.2,
  2079  			x1:     0.6,
  2080  			y1:     4.2,
  2081  			d1Want: 14 / 75.0,
  2082  			d2Want: 49 / 75.0,
  2083  			x1Want: 4.5,
  2084  			pWant: blas.DrotmParams{
  2085  				Flag: blas.Diagonal,
  2086  				H:    [4]float64{0.5, 0, 0, 1 / 7.0},
  2087  			},
  2088  		},
  2089  		{
  2090  			name:   "netlib/BLAS/TESTING#3",
  2091  			d1:     0,
  2092  			d2:     0,
  2093  			x1:     0,
  2094  			y1:     0,
  2095  			d1Want: 0,
  2096  			d2Want: 0,
  2097  			x1Want: 0,
  2098  			pWant: blas.DrotmParams{
  2099  				Flag: blas.Identity,
  2100  				H:    [4]float64{0, 0, 0, 0},
  2101  			},
  2102  		},
  2103  		{
  2104  			name:   "netlib/BLAS/TESTING#4",
  2105  			d1:     4,
  2106  			d2:     -1,
  2107  			x1:     2,
  2108  			y1:     4,
  2109  			d1Want: 0,
  2110  			d2Want: 0,
  2111  			x1Want: 0,
  2112  			pWant: blas.DrotmParams{
  2113  				Flag: blas.Rescaling,
  2114  				H:    [4]float64{0, 0, 0, 0},
  2115  			},
  2116  		},
  2117  		{
  2118  			name:   "netlib/BLAS/TESTING#5",
  2119  			d1:     6e-10,
  2120  			d2:     2e-2,
  2121  			x1:     1e5,
  2122  			y1:     10,
  2123  			d1Want: 45e-11 * 4096 * 4096,
  2124  			d2Want: 15e-3,
  2125  			x1Want: 4e5 / (3 * 4096),
  2126  			pWant: blas.DrotmParams{
  2127  				Flag: blas.Rescaling,
  2128  				H:    [4]float64{1 / 4096.0, -1e-4, 1e4 / (3 * 4096), 1},
  2129  			},
  2130  		},
  2131  		{
  2132  			name:   "netlib/BLAS/TESTING#6",
  2133  			d1:     4e10,
  2134  			d2:     2e-2,
  2135  			x1:     1e-5,
  2136  			y1:     10,
  2137  			d1Want: 4e10 / (1.5 * 4096 * 4096),
  2138  			d2Want: 2e-2 / 1.5,
  2139  			x1Want: 6.144e-2,
  2140  			pWant: blas.DrotmParams{
  2141  				Flag: blas.Rescaling,
  2142  				H:    [4]float64{4096, -1e6, 5e-7 * 4096, 1},
  2143  			},
  2144  		},
  2145  		{
  2146  			name:   "netlib/BLAS/TESTING#7",
  2147  			d1:     2e-10,
  2148  			d2:     4e-2,
  2149  			x1:     1e5,
  2150  			y1:     10,
  2151  			d1Want: 4 / 150.0,
  2152  			d2Want: (2e-10 / 1.5) * 4096 * 4096,
  2153  			x1Want: 15,
  2154  			pWant: blas.DrotmParams{
  2155  				Flag: blas.Rescaling,
  2156  				H:    [4]float64{5e-5, -1 / 4096.0, 1, 1e4 / 4096},
  2157  			},
  2158  		},
  2159  		{
  2160  			name:   "netlib/BLAS/TESTING#8",
  2161  			d1:     2e10,
  2162  			d2:     4e-2,
  2163  			x1:     1e-5,
  2164  			y1:     10,
  2165  			d1Want: 4 / 150.0,
  2166  			d2Want: 2e10 / (1.5 * 4096 * 4096),
  2167  			x1Want: 15,
  2168  			pWant: blas.DrotmParams{
  2169  				Flag: blas.Rescaling,
  2170  				H:    [4]float64{5e5, -4096, 1, 4.096e-3},
  2171  			},
  2172  		},
  2173  	}
  2174  
  2175  	for _, test := range tests {
  2176  		p, d1, d2, x1 := d.Drotmg(test.d1, test.d2, test.x1, test.y1)
  2177  
  2178  		if p.Flag != test.pWant.Flag {
  2179  			t.Errorf("%v: unexpected flag, want %v, got %v", test.name, test.pWant.Flag, p.Flag)
  2180  		}
  2181  		for i, hi := range p.H {
  2182  			if !scalar.EqualWithinAbsOrRel(test.pWant.H[i], hi, tol, tol) {
  2183  				t.Errorf("%v: unexpected H, want %v, got %v", test.name, test.pWant.H, p.H)
  2184  				break
  2185  			}
  2186  		}
  2187  		if !scalar.EqualWithinAbsOrRel(d1, test.d1Want, tol, tol) {
  2188  			t.Errorf("%v: unexpected d1, want %v, got %v", test.name, test.d1Want, d1)
  2189  		}
  2190  		if !scalar.EqualWithinAbsOrRel(d2, test.d2Want, tol, tol) {
  2191  			t.Errorf("%v: unexpected d2, want %v, got %v", test.name, test.d2Want, d2)
  2192  		}
  2193  		if !scalar.EqualWithinAbsOrRel(x1, test.x1Want, tol, tol) {
  2194  			t.Errorf("%v: unexpected x1, want %v, got %v", test.name, test.x1Want, x1)
  2195  		}
  2196  
  2197  		// Drotmg routines compute the components of a modified Givens transformation
  2198  		// matrix H that zeros the y-component of the resulting vector,
  2199  		//
  2200  		//  [x1; 0] := H[x1 sqrt(d1); y1 sqrt(d2)].
  2201  		//
  2202  		// Drotm performs a modified Givens rotation of points in the plane,
  2203  		//
  2204  		//  [x1; y1] := H[x1; y1].
  2205  		y := []float64{test.y1}
  2206  		d.Drotm(1, []float64{test.x1}, 1, y, 1, p)
  2207  		if d2 >= 0 {
  2208  			y[0] *= math.Sqrt(d2)
  2209  		}
  2210  		if !scalar.EqualWithinAbs(y[0], 0, 1e-10) {
  2211  			t.Errorf("%v: y1 not zeroed out, got %v", test.name, y[0])
  2212  		}
  2213  	}
  2214  }
  2215  
  2216  type Droter interface {
  2217  	Drot(n int, x []float64, incX int, y []float64, incY int, c, s float64)
  2218  }
  2219  
  2220  func DrotTest(t *testing.T, d Droter) {
  2221  	drot := d.Drot
  2222  	for _, c := range DoubleTwoVectorCases {
  2223  		for _, kind := range c.DrotCases {
  2224  			dCopyTwoTmp(c.X, c.XTmp, c.Y, c.YTmp)
  2225  			if c.Panic {
  2226  				f := func() { drot(c.N, c.XTmp, c.Incx, c.YTmp, c.Incy, kind.C, kind.S) }
  2227  				testpanics(f, c.Name, t)
  2228  				continue
  2229  			}
  2230  			drot(c.N, c.XTmp, c.Incx, c.YTmp, c.Incy, kind.C, kind.S)
  2231  			if !dSliceTolEqual(c.XTmp, kind.XAns) {
  2232  				t.Errorf("drot: x mismatch %v: expected %v, found %v", c.Name, kind.XAns, c.XTmp)
  2233  			}
  2234  			if !dSliceTolEqual(c.YTmp, kind.YAns) {
  2235  				t.Errorf("drot: y mismatch %v: expected %v, found %v", c.Name, kind.YAns, c.YTmp)
  2236  			}
  2237  		}
  2238  	}
  2239  }
  2240  
  2241  type Drotmer interface {
  2242  	Drotm(n int, x []float64, incX int, y []float64, incY int, p blas.DrotmParams)
  2243  }
  2244  
  2245  func DrotmTest(t *testing.T, d Drotmer) {
  2246  	drotm := d.Drotm
  2247  	for _, c := range DoubleTwoVectorCases {
  2248  		for _, kind := range c.DrotmCases {
  2249  			dCopyTwoTmp(c.X, c.XTmp, c.Y, c.YTmp)
  2250  			if c.Panic {
  2251  				f := func() { drotm(c.N, c.XTmp, c.Incx, c.YTmp, c.Incy, kind.P) }
  2252  				testpanics(f, c.Name+", "+kind.Name, t)
  2253  				continue
  2254  			}
  2255  			drotm(c.N, c.XTmp, c.Incx, c.YTmp, c.Incy, kind.P)
  2256  			if !dSliceTolEqual(c.XTmp, kind.XAns) {
  2257  				t.Errorf("drotm: mismatch %v: expected %v, found %v", c.Name, kind.XAns, c.XTmp)
  2258  			}
  2259  			if !dSliceTolEqual(c.YTmp, kind.YAns) {
  2260  				t.Errorf("drotm: mismatch %v: expected %v, found %v", c.Name, kind.YAns, c.YTmp)
  2261  			}
  2262  		}
  2263  	}
  2264  }
  2265  
  2266  type Dscaler interface {
  2267  	Dscal(n int, alpha float64, x []float64, incX int)
  2268  }
  2269  
  2270  func DscalTest(t *testing.T, blasser Dscaler) {
  2271  	dscal := blasser.Dscal
  2272  	for _, c := range DoubleOneVectorCases {
  2273  		for _, kind := range c.DscalCases {
  2274  			xTmp := make([]float64, len(c.X))
  2275  			copy(xTmp, c.X)
  2276  			if c.Panic {
  2277  				f := func() { dscal(c.N, kind.Alpha, xTmp, c.Incx) }
  2278  				testpanics(f, c.Name, t)
  2279  				continue
  2280  			}
  2281  			dscal(c.N, kind.Alpha, xTmp, c.Incx)
  2282  			if !dSliceTolEqual(xTmp, kind.Ans) {
  2283  				t.Errorf("dscal: mismatch %v, %v: expected %v, found %v", c.Name, kind.Name, kind.Ans, xTmp)
  2284  			}
  2285  		}
  2286  	}
  2287  }