From e7294311a0db01e06866ccef263430612c5dcf88 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Tue, 9 Jan 2018 12:37:46 -0800 Subject: [PATCH] vendor: update import paths to "gonum.org/v1" Signed-off-by: Gyuho Lee --- Gopkg.lock | 104 +- Gopkg.toml | 4 +- analyze/05_plot.go | 8 +- dbtesterpb/util.go | 2 +- .../gonum/blas/native/general_double.go | 155 -- .../gonum/blas/native/general_single.go | 157 -- .../github.com/gonum/internal/asm/f32/ddot.go | 33 - .../github.com/gonum/internal/asm/f32/dot.go | 33 - vendor/github.com/gonum/matrix/doc.go | 103 -- vendor/github.com/gonum/matrix/gendoc.go | 343 ----- vendor/github.com/gonum/matrix/generate.go | 7 - .../gonum/matrix/mat64/index_bound_checks.go | 145 -- .../matrix/mat64/index_no_bound_checks.go | 145 -- vendor/github.com/gonum/matrix/mat64/inner.go | 103 -- vendor/github.com/gonum/matrix/mat64/lq.go | 217 --- vendor/github.com/gonum/matrix/mat64/qr.go | 183 --- .../github.com/gonum/matrix/mat64/shadow.go | 281 ---- .../github.com/gonum/matrix/mat64/vector.go | 468 ------ .../github.com/gonum/plot/plotter/bubbles.go | 118 -- vendor/gonum.org/v1/gonum/LICENSE | 23 + .../v1}/gonum/blas/blas.go | 105 +- .../v1}/gonum/blas/blas64/blas64.go | 9 +- vendor/gonum.org/v1/gonum/blas/blas64/conv.go | 277 ++++ .../v1/gonum/blas/blas64/conv_symmetric.go | 153 ++ vendor/gonum.org/v1/gonum/blas/blas64/doc.go | 6 + vendor/gonum.org/v1/gonum/blas/doc.go | 108 ++ vendor/gonum.org/v1/gonum/blas/gonum/cmplx.go | 185 +++ .../v1/gonum/blas/gonum}/dgemm.go | 35 +- .../v1/gonum/blas/gonum}/doc.go | 8 +- .../v1/gonum/blas/gonum/general_double.go | 50 + .../v1/gonum/blas/gonum/general_single.go | 52 + .../v1/gonum/blas/gonum/gonum.go} | 73 +- .../v1/gonum/blas/gonum/level1cmplx128.go | 442 ++++++ .../v1/gonum/blas/gonum}/level1double.go | 27 +- .../v1/gonum/blas/gonum}/level1double_ddot.go | 6 +- .../v1/gonum/blas/gonum}/level1single.go | 31 +- .../gonum/blas/gonum}/level1single_dsdot.go | 8 +- .../v1/gonum/blas/gonum}/level1single_sdot.go | 8 +- .../gonum/blas/gonum}/level1single_sdsdot.go | 8 +- .../v1/gonum/blas/gonum/level2cmplx128.go | 1321 +++++++++++++++++ .../v1/gonum/blas/gonum}/level2double.go | 37 +- .../v1/gonum/blas/gonum}/level2single.go | 39 +- .../v1/gonum/blas/gonum}/level3double.go | 8 +- .../v1/gonum/blas/gonum}/level3single.go | 10 +- .../v1/gonum/blas/gonum}/sgemm.go | 37 +- vendor/gonum.org/v1/gonum/floats/doc.go | 11 + .../v1}/gonum/floats/floats.go | 50 +- .../gonum/internal/asm/c128/axpyinc_amd64.s | 134 ++ .../gonum/internal/asm/c128/axpyincto_amd64.s | 141 ++ .../internal/asm/c128/axpyunitary_amd64.s | 122 ++ .../internal/asm/c128/axpyunitaryto_amd64.s | 123 ++ .../v1/gonum/internal/asm/c128/doc.go | 6 + .../gonum/internal/asm/c128/dotcinc_amd64.s | 153 ++ .../internal/asm/c128/dotcunitary_amd64.s | 143 ++ .../gonum/internal/asm/c128/dotuinc_amd64.s | 141 ++ .../internal/asm/c128/dotuunitary_amd64.s | 130 ++ .../gonum/internal/asm/c128/dscalinc_amd64.s | 69 + .../internal/asm/c128/dscalunitary_amd64.s | 66 + .../v1/gonum/internal/asm/c128/scal.go | 31 + .../internal/asm/c128/scalUnitary_amd64.s | 116 ++ .../gonum/internal/asm/c128/scalinc_amd64.s | 121 ++ .../v1/gonum/internal/asm/c128/stubs_amd64.go | 96 ++ .../v1/gonum/internal/asm/c128/stubs_noasm.go | 163 ++ .../gonum/internal/asm/f32/axpyinc_amd64.s | 2 +- .../gonum/internal/asm/f32/axpyincto_amd64.s | 2 +- .../internal/asm/f32/axpyunitary_amd64.s | 2 +- .../internal/asm/f32/axpyunitaryto_amd64.s | 2 +- .../v1/gonum/internal/asm/f32/ddotinc_amd64.s | 91 ++ .../internal/asm/f32/ddotunitary_amd64.s | 110 ++ .../v1}/gonum/internal/asm/f32/doc.go | 4 +- .../v1/gonum/internal/asm/f32/dotinc_amd64.s | 85 ++ .../gonum/internal/asm/f32/dotunitary_amd64.s | 106 ++ .../v1}/gonum/internal/asm/f32/scal.go | 2 +- .../v1}/gonum/internal/asm/f32/stubs_amd64.go | 34 +- .../v1}/gonum/internal/asm/f32/stubs_noasm.go | 58 +- .../v1}/gonum/internal/asm/f64/abssum_amd64.s | 2 +- .../gonum/internal/asm/f64/abssuminc_amd64.s | 2 +- .../v1}/gonum/internal/asm/f64/add_amd64.s | 2 +- .../gonum/internal/asm/f64/addconst_amd64.s | 2 +- .../v1}/gonum/internal/asm/f64/axpy.go | 2 +- .../gonum/internal/asm/f64/axpyinc_amd64.s | 2 +- .../gonum/internal/asm/f64/axpyincto_amd64.s | 2 +- .../internal/asm/f64/axpyunitary_amd64.s | 2 +- .../internal/asm/f64/axpyunitaryto_amd64.s | 2 +- .../gonum/internal/asm/f64/cumprod_amd64.s | 2 +- .../v1}/gonum/internal/asm/f64/cumsum_amd64.s | 2 +- .../v1}/gonum/internal/asm/f64/div_amd64.s | 2 +- .../v1}/gonum/internal/asm/f64/divto_amd64.s | 2 +- .../v1}/gonum/internal/asm/f64/doc.go | 4 +- .../v1}/gonum/internal/asm/f64/dot.go | 2 +- .../v1}/gonum/internal/asm/f64/dot_amd64.s | 2 +- .../v1}/gonum/internal/asm/f64/l1norm_amd64.s | 2 +- .../gonum/internal/asm/f64/linfnorm_amd64.s | 2 +- .../v1}/gonum/internal/asm/f64/scal.go | 2 +- .../gonum/internal/asm/f64/scalinc_amd64.s | 2 +- .../gonum/internal/asm/f64/scalincto_amd64.s | 2 +- .../internal/asm/f64/scalunitary_amd64.s | 2 +- .../internal/asm/f64/scalunitaryto_amd64.s | 2 +- .../v1}/gonum/internal/asm/f64/stubs_amd64.go | 2 +- .../v1}/gonum/internal/asm/f64/stubs_noasm.go | 2 +- .../gonum.org/v1/gonum/internal/math32/doc.go | 7 + .../v1/gonum}/internal/math32/math.go | 4 +- .../v1/gonum/internal/math32/signbit.go | 16 + .../v1/gonum}/internal/math32/sqrt.go | 2 +- .../v1/gonum}/internal/math32/sqrt_amd64.go | 2 +- .../v1/gonum}/internal/math32/sqrt_amd64.s | 2 +- .../v1/gonum/lapack/gonum}/dbdsqr.go | 10 +- .../v1/gonum/lapack/gonum}/dgebak.go | 10 +- .../v1/gonum/lapack/gonum}/dgebal.go | 8 +- .../v1/gonum/lapack/gonum}/dgebd2.go | 6 +- .../v1/gonum/lapack/gonum}/dgebrd.go | 8 +- .../v1/gonum/lapack/gonum}/dgecon.go | 10 +- .../v1/gonum/lapack/gonum}/dgeev.go | 10 +- .../v1/gonum/lapack/gonum}/dgehd2.go | 6 +- .../v1/gonum/lapack/gonum}/dgehrd.go | 10 +- .../v1/gonum/lapack/gonum}/dgelq2.go | 6 +- .../v1/gonum/lapack/gonum}/dgelqf.go | 8 +- .../v1/gonum/lapack/gonum}/dgels.go | 8 +- .../v1/gonum/lapack/gonum}/dgeql2.go | 6 +- .../v1/gonum/lapack/gonum}/dgeqp3.go | 8 +- .../v1/gonum/lapack/gonum}/dgeqr2.go | 6 +- .../v1/gonum/lapack/gonum}/dgeqrf.go | 8 +- .../v1/gonum/lapack/gonum}/dgerq2.go | 6 +- .../v1/gonum/lapack/gonum}/dgerqf.go | 8 +- .../v1/gonum/lapack/gonum}/dgesvd.go | 12 +- .../v1/gonum/lapack/gonum}/dgetf2.go | 6 +- .../v1/gonum/lapack/gonum}/dgetrf.go | 8 +- .../v1/gonum/lapack/gonum}/dgetri.go | 8 +- .../v1/gonum/lapack/gonum}/dgetrs.go | 8 +- .../v1/gonum/lapack/gonum}/dggsvd3.go | 8 +- .../v1/gonum/lapack/gonum}/dggsvp3.go | 8 +- .../v1/gonum/lapack/gonum}/dhseqr.go | 8 +- .../v1/gonum/lapack/gonum}/dlabrd.go | 8 +- .../v1/gonum/lapack/gonum}/dlacn2.go | 6 +- .../v1/gonum/lapack/gonum}/dlacpy.go | 6 +- .../v1/gonum/lapack/gonum}/dlae2.go | 4 +- .../v1/gonum/lapack/gonum}/dlaev2.go | 4 +- .../v1/gonum/lapack/gonum}/dlaexc.go | 10 +- .../v1/gonum/lapack/gonum}/dlags2.go | 4 +- .../v1/gonum/lapack/gonum}/dlahqr.go | 8 +- .../v1/gonum/lapack/gonum}/dlahr2.go | 8 +- .../v1/gonum/lapack/gonum}/dlaln2.go | 4 +- .../v1/gonum/lapack/gonum}/dlange.go | 6 +- .../v1/gonum/lapack/gonum}/dlanst.go | 6 +- .../v1/gonum/lapack/gonum}/dlansy.go | 8 +- .../v1/gonum/lapack/gonum}/dlantr.go | 8 +- .../v1/gonum/lapack/gonum}/dlanv2.go | 4 +- .../v1/gonum/lapack/gonum}/dlapll.go | 6 +- .../v1/gonum/lapack/gonum}/dlapmt.go | 6 +- .../v1/gonum/lapack/gonum}/dlapy2.go | 4 +- .../v1/gonum/lapack/gonum}/dlaqp2.go | 8 +- .../v1/gonum/lapack/gonum}/dlaqps.go | 8 +- .../v1/gonum/lapack/gonum}/dlaqr04.go | 6 +- .../v1/gonum/lapack/gonum}/dlaqr1.go | 4 +- .../v1/gonum/lapack/gonum}/dlaqr23.go | 10 +- .../v1/gonum/lapack/gonum}/dlaqr5.go | 8 +- .../v1/gonum/lapack/gonum}/dlarf.go | 8 +- .../v1/gonum/lapack/gonum}/dlarfb.go | 10 +- .../v1/gonum/lapack/gonum}/dlarfg.go | 6 +- .../v1/gonum/lapack/gonum}/dlarft.go | 12 +- .../v1/gonum/lapack/gonum}/dlarfx.go | 6 +- .../v1/gonum/lapack/gonum}/dlartg.go | 4 +- .../v1/gonum/lapack/gonum}/dlas2.go | 4 +- .../v1/gonum/lapack/gonum}/dlascl.go | 6 +- .../v1/gonum/lapack/gonum}/dlaset.go | 6 +- .../v1/gonum/lapack/gonum}/dlasq1.go | 8 +- .../v1/gonum/lapack/gonum}/dlasq2.go | 10 +- .../v1/gonum/lapack/gonum}/dlasq3.go | 4 +- .../v1/gonum/lapack/gonum}/dlasq4.go | 5 +- .../v1/gonum/lapack/gonum}/dlasq5.go | 10 +- .../v1/gonum/lapack/gonum}/dlasq6.go | 4 +- .../v1/gonum/lapack/gonum}/dlasr.go | 8 +- .../v1/gonum/lapack/gonum}/dlasrt.go | 6 +- .../v1/gonum/lapack/gonum}/dlassq.go | 4 +- .../v1/gonum/lapack/gonum}/dlasv2.go | 4 +- .../v1/gonum/lapack/gonum}/dlaswp.go | 6 +- .../v1/gonum/lapack/gonum}/dlasy2.go | 6 +- .../v1/gonum/lapack/gonum}/dlatrd.go | 8 +- .../v1/gonum/lapack/gonum}/dlatrs.go | 8 +- .../v1/gonum/lapack/gonum}/doc.go | 12 +- .../v1/gonum/lapack/gonum}/dorg2l.go | 8 +- .../v1/gonum/lapack/gonum}/dorg2r.go | 8 +- .../v1/gonum/lapack/gonum}/dorgbr.go | 6 +- .../v1/gonum/lapack/gonum}/dorghr.go | 4 +- .../v1/gonum/lapack/gonum}/dorgl2.go | 8 +- .../v1/gonum/lapack/gonum}/dorglq.go | 8 +- .../v1/gonum/lapack/gonum}/dorgql.go | 8 +- .../v1/gonum/lapack/gonum}/dorgqr.go | 8 +- .../v1/gonum/lapack/gonum}/dorgtr.go | 6 +- .../v1/gonum/lapack/gonum}/dorm2r.go | 6 +- .../v1/gonum/lapack/gonum}/dormbr.go | 8 +- .../v1/gonum/lapack/gonum}/dormhr.go | 6 +- .../v1/gonum/lapack/gonum}/dorml2.go | 6 +- .../v1/gonum/lapack/gonum}/dormlq.go | 8 +- .../v1/gonum/lapack/gonum}/dormqr.go | 8 +- .../v1/gonum/lapack/gonum}/dormr2.go | 6 +- .../gonum.org/v1/gonum/lapack/gonum/dpbtf2.go | 97 ++ .../v1/gonum/lapack/gonum}/dpocon.go | 8 +- .../v1/gonum/lapack/gonum}/dpotf2.go | 8 +- .../v1/gonum/lapack/gonum}/dpotrf.go | 8 +- .../v1/gonum/lapack/gonum}/drscl.go | 6 +- .../v1/gonum/lapack/gonum}/dsteqr.go | 13 +- .../v1/gonum/lapack/gonum}/dsterf.go | 6 +- .../v1/gonum/lapack/gonum}/dsyev.go | 10 +- .../v1/gonum/lapack/gonum}/dsytd2.go | 8 +- .../v1/gonum/lapack/gonum}/dsytrd.go | 8 +- .../v1/gonum/lapack/gonum}/dtgsja.go | 10 +- .../v1/gonum/lapack/gonum}/dtrcon.go | 10 +- .../v1/gonum/lapack/gonum}/dtrevc3.go | 12 +- .../v1/gonum/lapack/gonum}/dtrexc.go | 6 +- .../v1/gonum/lapack/gonum}/dtrti2.go | 8 +- .../v1/gonum/lapack/gonum}/dtrtri.go | 8 +- .../v1/gonum/lapack/gonum}/dtrtrs.go | 8 +- .../v1/gonum/lapack/gonum}/general.go | 23 +- .../v1/gonum/lapack/gonum}/iladlc.go | 4 +- .../v1/gonum/lapack/gonum}/iladlr.go | 4 +- .../v1/gonum/lapack/gonum}/ilaenv.go | 4 +- .../v1/gonum/lapack/gonum}/iparmq.go | 4 +- .../v1}/gonum/lapack/lapack.go | 6 +- .../gonum.org/v1/gonum/lapack/lapack64/doc.go | 20 + .../v1}/gonum/lapack/lapack64/lapack64.go | 27 +- vendor/gonum.org/v1/gonum/mat/band.go | 228 +++ .../v1/gonum/mat}/cholesky.go | 343 +++-- vendor/gonum.org/v1/gonum/mat/cmatrix.go | 71 + .../v1/gonum/mat}/consts.go | 4 +- .../mat64 => gonum.org/v1/gonum/mat}/dense.go | 101 +- .../v1/gonum/mat}/dense_arithmetic.go | 76 +- .../mat64 => gonum.org/v1/gonum/mat}/doc.go | 109 +- .../mat64 => gonum.org/v1/gonum/mat}/eigen.go | 49 +- .../v1/gonum/mat}/errors.go | 21 +- .../v1/gonum/mat}/format.go | 4 +- .../mat64 => gonum.org/v1/gonum/mat}/gsvd.go | 163 +- .../v1/gonum/mat}/hogsvd.go | 70 +- .../v1/gonum/mat/index_bound_checks.go | 233 +++ .../v1/gonum/mat/index_no_bound_checks.go | 237 +++ vendor/gonum.org/v1/gonum/mat/inner.go | 121 ++ .../mat64 => gonum.org/v1/gonum/mat}/io.go | 44 +- vendor/gonum.org/v1/gonum/mat/lq.go | 235 +++ .../mat64 => gonum.org/v1/gonum/mat}/lu.go | 218 +-- .../v1/gonum/mat}/matrix.go | 164 +- .../v1/gonum/mat}/offset.go | 4 +- .../v1/gonum/mat}/offset_appengine.go | 4 +- .../mat64 => gonum.org/v1/gonum/mat}/pool.go | 114 +- .../v1/gonum/mat}/product.go | 22 +- vendor/gonum.org/v1/gonum/mat/qr.go | 233 +++ vendor/gonum.org/v1/gonum/mat/shadow.go | 172 +++ .../mat64 => gonum.org/v1/gonum/mat}/solve.go | 74 +- .../mat64 => gonum.org/v1/gonum/mat}/svd.go | 74 +- vendor/gonum.org/v1/gonum/mat/symband.go | 175 +++ .../v1/gonum/mat}/symmetric.go | 102 +- .../v1/gonum/mat}/triangular.go | 213 ++- vendor/gonum.org/v1/gonum/mat/vector.go | 711 +++++++++ .../gonum => gonum.org/v1}/plot/LICENSE | 0 vendor/gonum.org/v1/plot/align.go | 117 ++ .../gonum => gonum.org/v1}/plot/axis.go | 187 ++- vendor/gonum.org/v1/plot/doc.go | 16 + vendor/gonum.org/v1/plot/labelling.go | 274 ++++ .../gonum => gonum.org/v1}/plot/legend.go | 6 +- .../v1}/plot/palette/hsva.go | 0 .../v1}/plot/palette/palette.go | 2 +- vendor/gonum.org/v1/plot/palette/reverse.go | 35 + .../gonum => gonum.org/v1}/plot/plot.go | 26 +- .../v1}/plot/plotter/barchart.go | 6 +- .../v1}/plot/plotter/boxplot.go | 6 +- .../v1}/plot/plotter/colorbar.go | 35 +- .../v1}/plot/plotter/conrec.go | 0 .../v1}/plot/plotter/contour.go | 14 +- .../v1}/plot/plotter/errbars.go | 6 +- .../v1}/plot/plotter/functions.go | 23 +- .../v1}/plot/plotter/glyphbox.go | 6 +- .../v1}/plot/plotter/grid.go | 6 +- .../v1}/plot/plotter/heat.go | 42 +- .../v1}/plot/plotter/histogram.go | 6 +- .../v1}/plot/plotter/image.go | 6 +- .../v1}/plot/plotter/johnson.go | 0 .../v1}/plot/plotter/labels.go | 6 +- .../v1}/plot/plotter/line.go | 6 +- .../v1}/plot/plotter/palettethumbnailer.go | 8 +- .../v1}/plot/plotter/plotter.go | 36 +- .../v1}/plot/plotter/polygon.go | 6 +- .../v1}/plot/plotter/quartile.go | 6 +- .../v1}/plot/plotter/sankey.go | 8 +- .../v1}/plot/plotter/scatter.go | 28 +- .../v1}/plot/plotter/volcano_example.go | 18 +- .../v1}/plot/plotutil/add.go | 6 +- .../v1}/plot/plotutil/errorpoints.go | 2 +- .../v1}/plot/plotutil/main.go | 6 +- .../v1}/plot/plotutil/plotutil.go | 16 +- .../v1}/plot/tools/bezier/bezier.go | 4 +- .../v1}/plot/vg/draw/canvas.go | 12 +- .../gonum => gonum.org/v1}/plot/vg/font.go | 3 +- .../v1}/plot/vg/font_syscall.go | 2 +- .../v1}/plot/vg/fonts/fonts.go | 2 +- .../vg/fonts/liberation_fonts_generated.go | 0 .../v1}/plot/vg/fonts/mk-fonts.go | 4 +- .../gonum => gonum.org/v1}/plot/vg/geom.go | 0 .../gonum => gonum.org/v1}/plot/vg/len.go | 0 .../gonum => gonum.org/v1}/plot/vg/vg.go | 2 +- .../v1}/plot/vg/vgeps/vgeps.go | 6 +- .../v1}/plot/vg/vgimg/vgimg.go | 22 +- .../v1}/plot/vg/vgpdf/vgpdf.go | 5 +- .../v1}/plot/vg/vgsvg/vgsvg.go | 5 +- 302 files changed, 10101 insertions(+), 4365 deletions(-) delete mode 100644 vendor/github.com/gonum/blas/native/general_double.go delete mode 100644 vendor/github.com/gonum/blas/native/general_single.go delete mode 100644 vendor/github.com/gonum/internal/asm/f32/ddot.go delete mode 100644 vendor/github.com/gonum/internal/asm/f32/dot.go delete mode 100644 vendor/github.com/gonum/matrix/doc.go delete mode 100644 vendor/github.com/gonum/matrix/gendoc.go delete mode 100644 vendor/github.com/gonum/matrix/generate.go delete mode 100644 vendor/github.com/gonum/matrix/mat64/index_bound_checks.go delete mode 100644 vendor/github.com/gonum/matrix/mat64/index_no_bound_checks.go delete mode 100644 vendor/github.com/gonum/matrix/mat64/inner.go delete mode 100644 vendor/github.com/gonum/matrix/mat64/lq.go delete mode 100644 vendor/github.com/gonum/matrix/mat64/qr.go delete mode 100644 vendor/github.com/gonum/matrix/mat64/shadow.go delete mode 100644 vendor/github.com/gonum/matrix/mat64/vector.go delete mode 100644 vendor/github.com/gonum/plot/plotter/bubbles.go create mode 100644 vendor/gonum.org/v1/gonum/LICENSE rename vendor/{github.com => gonum.org/v1}/gonum/blas/blas.go (74%) rename vendor/{github.com => gonum.org/v1}/gonum/blas/blas64/blas64.go (98%) create mode 100644 vendor/gonum.org/v1/gonum/blas/blas64/conv.go create mode 100644 vendor/gonum.org/v1/gonum/blas/blas64/conv_symmetric.go create mode 100644 vendor/gonum.org/v1/gonum/blas/blas64/doc.go create mode 100644 vendor/gonum.org/v1/gonum/blas/doc.go create mode 100644 vendor/gonum.org/v1/gonum/blas/gonum/cmplx.go rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/dgemm.go (92%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/doc.go (92%) create mode 100644 vendor/gonum.org/v1/gonum/blas/gonum/general_double.go create mode 100644 vendor/gonum.org/v1/gonum/blas/gonum/general_single.go rename vendor/{github.com/gonum/blas/native/native.go => gonum.org/v1/gonum/blas/gonum/gonum.go} (51%) create mode 100644 vendor/gonum.org/v1/gonum/blas/gonum/level1cmplx128.go rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/level1double.go (96%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/level1double_ddot.go (88%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/level1single.go (95%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/level1single_dsdot.go (83%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/level1single_sdot.go (83%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/level1single_sdsdot.go (84%) create mode 100644 vendor/gonum.org/v1/gonum/blas/gonum/level2cmplx128.go rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/level2double.go (98%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/level2single.go (98%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/level3double.go (99%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/level3single.go (98%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum/blas/gonum}/sgemm.go (91%) create mode 100644 vendor/gonum.org/v1/gonum/floats/doc.go rename vendor/{github.com => gonum.org/v1}/gonum/floats/floats.go (94%) create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/axpyinc_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/axpyincto_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/axpyunitary_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/axpyunitaryto_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/doc.go create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/dotcinc_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/dotcunitary_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/dotuinc_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/dotuunitary_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/dscalinc_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/dscalunitary_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/scal.go create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/scalUnitary_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/scalinc_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/stubs_amd64.go create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/c128/stubs_noasm.go rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f32/axpyinc_amd64.s (97%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f32/axpyincto_amd64.s (97%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f32/axpyunitary_amd64.s (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f32/axpyunitaryto_amd64.s (98%) create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/f32/ddotinc_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/f32/ddotunitary_amd64.s rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f32/doc.go (56%) create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/f32/dotinc_amd64.s create mode 100644 vendor/gonum.org/v1/gonum/internal/asm/f32/dotunitary_amd64.s rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f32/scal.go (94%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f32/stubs_amd64.go (53%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f32/stubs_noasm.go (51%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/abssum_amd64.s (97%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/abssuminc_amd64.s (97%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/add_amd64.s (96%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/addconst_amd64.s (96%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/axpy.go (95%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/axpyinc_amd64.s (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/axpyincto_amd64.s (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/axpyunitary_amd64.s (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/axpyunitaryto_amd64.s (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/cumprod_amd64.s (97%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/cumsum_amd64.s (96%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/div_amd64.s (96%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/divto_amd64.s (97%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/doc.go (56%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/dot.go (91%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/dot_amd64.s (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/l1norm_amd64.s (96%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/linfnorm_amd64.s (96%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/scal.go (94%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/scalinc_amd64.s (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/scalincto_amd64.s (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/scalunitary_amd64.s (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/scalunitaryto_amd64.s (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/stubs_amd64.go (98%) rename vendor/{github.com => gonum.org/v1}/gonum/internal/asm/f64/stubs_noasm.go (97%) create mode 100644 vendor/gonum.org/v1/gonum/internal/math32/doc.go rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum}/internal/math32/math.go (93%) create mode 100644 vendor/gonum.org/v1/gonum/internal/math32/signbit.go rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum}/internal/math32/sqrt.go (90%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum}/internal/math32/sqrt_amd64.go (88%) rename vendor/{github.com/gonum/blas/native => gonum.org/v1/gonum}/internal/math32/sqrt_amd64.s (90%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dbdsqr.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgebak.go (92%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgebal.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgebd2.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgebrd.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgecon.go (92%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgeev.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgehd2.go (96%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgehrd.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgelq2.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgelqf.go (94%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgels.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgeql2.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgeqp3.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgeqr2.go (94%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgeqrf.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgerq2.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgerqf.go (96%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgesvd.go (99%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgetf2.go (94%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgetrf.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgetri.go (94%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dgetrs.go (92%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dggsvd3.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dggsvp3.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dhseqr.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlabrd.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlacn2.go (96%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlacpy.go (89%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlae2.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaev2.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaexc.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlags2.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlahqr.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlahr2.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaln2.go (99%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlange.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlanst.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlansy.go (94%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlantr.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlanv2.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlapll.go (90%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlapmt.go (91%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlapy2.go (81%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaqp2.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaqps.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaqr04.go (99%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaqr1.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaqr23.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaqr5.go (99%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlarf.go (94%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlarfb.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlarfg.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlarft.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlarfx.go (99%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlartg.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlas2.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlascl.go (94%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaset.go (90%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlasq1.go (94%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlasq2.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlasq3.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlasq4.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlasq5.go (92%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlasq6.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlasr.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlasrt.go (87%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlassq.go (92%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlasv2.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlaswp.go (91%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlasy2.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlatrd.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dlatrs.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/doc.go (71%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorg2l.go (91%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorg2r.go (91%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorgbr.go (96%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorghr.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorgl2.go (90%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorglq.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorgql.go (96%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorgqr.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorgtr.go (96%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorm2r.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dormbr.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dormhr.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dorml2.go (95%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dormlq.go (96%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dormqr.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dormr2.go (95%) create mode 100644 vendor/gonum.org/v1/gonum/lapack/gonum/dpbtf2.go rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dpocon.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dpotf2.go (92%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dpotrf.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/drscl.go (89%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dsteqr.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dsterf.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dsyev.go (94%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dsytd2.go (96%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dsytrd.go (97%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dtgsja.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dtrcon.go (91%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dtrevc3.go (99%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dtrexc.go (98%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dtrti2.go (90%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dtrtri.go (93%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/dtrtrs.go (84%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/general.go (90%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/iladlc.go (90%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/iladlr.go (89%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/ilaenv.go (99%) rename vendor/{github.com/gonum/lapack/native => gonum.org/v1/gonum/lapack/gonum}/iparmq.go (97%) rename vendor/{github.com => gonum.org/v1}/gonum/lapack/lapack.go (97%) create mode 100644 vendor/gonum.org/v1/gonum/lapack/lapack64/doc.go rename vendor/{github.com => gonum.org/v1}/gonum/lapack/lapack64/lapack64.go (95%) create mode 100644 vendor/gonum.org/v1/gonum/mat/band.go rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/cholesky.go (55%) create mode 100644 vendor/gonum.org/v1/gonum/mat/cmatrix.go rename vendor/{github.com/gonum/matrix => gonum.org/v1/gonum/mat}/consts.go (95%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/dense.go (87%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/dense_arithmetic.go (92%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/doc.go (58%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/eigen.go (89%) rename vendor/{github.com/gonum/matrix => gonum.org/v1/gonum/mat}/errors.go (89%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/format.go (98%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/gsvd.go (64%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/hogsvd.go (73%) create mode 100644 vendor/gonum.org/v1/gonum/mat/index_bound_checks.go create mode 100644 vendor/gonum.org/v1/gonum/mat/index_no_bound_checks.go create mode 100644 vendor/gonum.org/v1/gonum/mat/inner.go rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/io.go (89%) create mode 100644 vendor/gonum.org/v1/gonum/mat/lq.go rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/lu.go (62%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/matrix.go (88%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/offset.go (88%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/offset_appengine.go (89%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/pool.go (57%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/product.go (94%) create mode 100644 vendor/gonum.org/v1/gonum/mat/qr.go create mode 100644 vendor/gonum.org/v1/gonum/mat/shadow.go rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/solve.go (60%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/svd.go (75%) create mode 100644 vendor/gonum.org/v1/gonum/mat/symband.go rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/symmetric.go (85%) rename vendor/{github.com/gonum/matrix/mat64 => gonum.org/v1/gonum/mat}/triangular.go (68%) create mode 100644 vendor/gonum.org/v1/gonum/mat/vector.go rename vendor/{github.com/gonum => gonum.org/v1}/plot/LICENSE (100%) create mode 100644 vendor/gonum.org/v1/plot/align.go rename vendor/{github.com/gonum => gonum.org/v1}/plot/axis.go (82%) create mode 100644 vendor/gonum.org/v1/plot/doc.go create mode 100644 vendor/gonum.org/v1/plot/labelling.go rename vendor/{github.com/gonum => gonum.org/v1}/plot/legend.go (97%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/palette/hsva.go (100%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/palette/palette.go (99%) create mode 100644 vendor/gonum.org/v1/plot/palette/reverse.go rename vendor/{github.com/gonum => gonum.org/v1}/plot/plot.go (93%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/barchart.go (98%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/boxplot.go (99%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/colorbar.go (85%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/conrec.go (100%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/contour.go (98%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/errbars.go (98%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/functions.go (77%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/glyphbox.go (91%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/grid.go (94%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/heat.go (88%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/histogram.go (98%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/image.go (95%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/johnson.go (100%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/labels.go (96%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/line.go (96%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/palettethumbnailer.go (89%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/plotter.go (87%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/polygon.go (97%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/quartile.go (98%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/sankey.go (99%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/scatter.go (70%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotter/volcano_example.go (98%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotutil/add.go (99%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotutil/errorpoints.go (98%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotutil/main.go (97%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/plotutil/plotutil.go (90%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/tools/bezier/bezier.go (95%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/draw/canvas.go (99%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/font.go (99%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/font_syscall.go (95%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/fonts/fonts.go (84%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/fonts/liberation_fonts_generated.go (100%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/fonts/mk-fonts.go (97%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/geom.go (100%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/len.go (100%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/vg.go (99%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/vgeps/vgeps.go (97%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/vgimg/vgimg.go (95%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/vgpdf/vgpdf.go (98%) rename vendor/{github.com/gonum => gonum.org/v1}/plot/vg/vgsvg/vgsvg.go (99%) diff --git a/Gopkg.lock b/Gopkg.lock index 2e1482f7..912942c2 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -99,70 +99,6 @@ revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845" source = "https://github.com/golang/protobuf" -[[projects]] - branch = "master" - name = "github.com/gonum/blas" - packages = [ - ".", - "blas64", - "native", - "native/internal/math32" - ] - revision = "37e82626499e1df7c54aeaba0959fd6e7e8dc1e4" - -[[projects]] - branch = "master" - name = "github.com/gonum/floats" - packages = ["."] - revision = "f74b330d45c56584a6ea7a27f5c64ea2900631e9" - -[[projects]] - branch = "master" - name = "github.com/gonum/internal" - packages = [ - "asm/f32", - "asm/f64" - ] - revision = "e57e4534cf9b3b00ef6c0175f59d8d2d34f60914" - -[[projects]] - branch = "master" - name = "github.com/gonum/lapack" - packages = [ - ".", - "lapack64", - "native" - ] - revision = "5ed4b826becd1807e09377508f51756586d1a98c" - -[[projects]] - branch = "master" - name = "github.com/gonum/matrix" - packages = [ - ".", - "mat64" - ] - revision = "dd6034299e4242c9f0ea36735e6d4264dfcb3f9f" - -[[projects]] - name = "github.com/gonum/plot" - packages = [ - ".", - "palette", - "plotter", - "plotutil", - "tools/bezier", - "vg", - "vg/draw", - "vg/fonts", - "vg/vgeps", - "vg/vgimg", - "vg/vgpdf", - "vg/vgsvg" - ] - revision = "51b62dc5319d7fce41240d13e780a93e640b9a38" - source = "https://github.com/gonum/plot" - [[projects]] name = "github.com/googleapis/gax-go" packages = ["."] @@ -344,6 +280,44 @@ revision = "6dc17368e09b0e8634d71cac8168d853e869a0c7" source = "https://github.com/golang/time" +[[projects]] + branch = "master" + name = "gonum.org/v1/gonum" + packages = [ + "blas", + "blas/blas64", + "blas/gonum", + "floats", + "internal/asm/c128", + "internal/asm/f32", + "internal/asm/f64", + "internal/math32", + "lapack", + "lapack/gonum", + "lapack/lapack64", + "mat" + ] + revision = "69fc04c7c31754cf196d3bcc70c3bc0eec9da1b7" + +[[projects]] + name = "gonum.org/v1/plot" + packages = [ + ".", + "palette", + "plotter", + "plotutil", + "tools/bezier", + "vg", + "vg/draw", + "vg/fonts", + "vg/vgeps", + "vg/vgimg", + "vg/vgpdf", + "vg/vgsvg" + ] + revision = "feab214a240f4312b98ab52baf662b55ff1ee377" + source = "https://github.com/gonum/plot" + [[projects]] name = "google.golang.org/api" packages = [ @@ -421,6 +395,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "057a961c21585211116e57f99b60e5bdd28cfe46411715ec4e13dbcf12ddd876" + inputs-digest = "21abf25cf507cffab0266c5836fb8acc3cb14f96b0f3fba49e0c55b85fedf5e5" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index f130fac9..de298c78 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -88,9 +88,9 @@ [[constraint]] - name = "github.com/gonum/plot" + name = "gonum.org/v1/plot" source = "https://github.com/gonum/plot" - revision = "51b62dc5319d7fce41240d13e780a93e640b9a38" + revision = "feab214a240f4312b98ab52baf662b55ff1ee377" [[constraint]] diff --git a/analyze/05_plot.go b/analyze/05_plot.go index 54ac71a2..ab074f6a 100644 --- a/analyze/05_plot.go +++ b/analyze/05_plot.go @@ -19,11 +19,11 @@ import ( "github.com/coreos/dbtester/dbtesterpb" - "github.com/gonum/plot" - "github.com/gonum/plot/plotter" - "github.com/gonum/plot/plotutil" - "github.com/gonum/plot/vg" "github.com/gyuho/dataframe" + "gonum.org/v1/plot" + "gonum.org/v1/plot/plotter" + "gonum.org/v1/plot/plotutil" + "gonum.org/v1/plot/vg" ) var ( diff --git a/dbtesterpb/util.go b/dbtesterpb/util.go index 5e900ad6..45f43aeb 100644 --- a/dbtesterpb/util.go +++ b/dbtesterpb/util.go @@ -18,7 +18,7 @@ import ( "image/color" "sort" - "github.com/gonum/plot/plotutil" + "gonum.org/v1/plot/plotutil" ) // IsValidDatabaseID returns false if the database id is not supported. diff --git a/vendor/github.com/gonum/blas/native/general_double.go b/vendor/github.com/gonum/blas/native/general_double.go deleted file mode 100644 index 0fa6cb74..00000000 --- a/vendor/github.com/gonum/blas/native/general_double.go +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright ©2014 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package native - -import ( - "errors" - "fmt" - "math" -) - -func newGeneral64(r, c int) general64 { - return general64{ - data: make([]float64, r*c), - rows: r, - cols: c, - stride: c, - } -} - -type general64 struct { - data []float64 - rows, cols int - stride int -} - -// adds element-wise into receiver. rows and columns must match -func (g general64) add(h general64) { - if debug { - if g.rows != h.rows { - panic("blas: row size mismatch") - } - if g.cols != h.cols { - panic("blas: col size mismatch") - } - } - for i := 0; i < g.rows; i++ { - gtmp := g.data[i*g.stride : i*g.stride+g.cols] - for j, v := range h.data[i*h.stride : i*h.stride+h.cols] { - gtmp[j] += v - } - } -} - -// at returns the value at the ith row and jth column. For speed reasons, the -// rows and columns are not bounds checked. -func (g general64) at(i, j int) float64 { - if debug { - if i < 0 || i >= g.rows { - panic("blas: row out of bounds") - } - if j < 0 || j >= g.cols { - panic("blas: col out of bounds") - } - } - return g.data[i*g.stride+j] -} - -func (g general64) check(c byte) error { - if g.rows < 0 { - return errors.New("blas: rows < 0") - } - if g.cols < 0 { - return errors.New("blas: cols < 0") - } - if g.stride < 1 { - return errors.New("blas: stride < 1") - } - if g.stride < g.cols { - return errors.New("blas: illegal stride") - } - if (g.rows-1)*g.stride+g.cols > len(g.data) { - return fmt.Errorf("blas: index of %c out of range", c) - } - return nil -} - -func (g general64) clone() general64 { - data := make([]float64, len(g.data)) - copy(data, g.data) - return general64{ - data: data, - rows: g.rows, - cols: g.cols, - stride: g.stride, - } -} - -// assumes they are the same size -func (g general64) copy(h general64) { - if debug { - if g.rows != h.rows { - panic("blas: row mismatch") - } - if g.cols != h.cols { - panic("blas: col mismatch") - } - } - for k := 0; k < g.rows; k++ { - copy(g.data[k*g.stride:(k+1)*g.stride], h.data[k*h.stride:(k+1)*h.stride]) - } -} - -func (g general64) equal(a general64) bool { - if g.rows != a.rows || g.cols != a.cols || g.stride != a.stride { - return false - } - for i, v := range g.data { - if a.data[i] != v { - return false - } - } - return true -} - -/* -// print is to aid debugging. Commented out to avoid fmt import -func (g general64) print() { - fmt.Println("r = ", g.rows, "c = ", g.cols, "stride: ", g.stride) - for i := 0; i < g.rows; i++ { - fmt.Println(g.data[i*g.stride : (i+1)*g.stride]) - } - -} -*/ - -func (g general64) view(i, j, r, c int) general64 { - if debug { - if i < 0 || i+r > g.rows { - panic("blas: row out of bounds") - } - if j < 0 || j+c > g.cols { - panic("blas: col out of bounds") - } - } - return general64{ - data: g.data[i*g.stride+j : (i+r-1)*g.stride+j+c], - rows: r, - cols: c, - stride: g.stride, - } -} - -func (g general64) equalWithinAbs(a general64, tol float64) bool { - if g.rows != a.rows || g.cols != a.cols || g.stride != a.stride { - return false - } - for i, v := range g.data { - if math.Abs(a.data[i]-v) > tol { - return false - } - } - return true -} diff --git a/vendor/github.com/gonum/blas/native/general_single.go b/vendor/github.com/gonum/blas/native/general_single.go deleted file mode 100644 index de1c263f..00000000 --- a/vendor/github.com/gonum/blas/native/general_single.go +++ /dev/null @@ -1,157 +0,0 @@ -// Code generated by "go generate github.com/gonum/blas/native"; DO NOT EDIT. - -// Copyright ©2014 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package native - -import ( - "errors" - "fmt" - math "github.com/gonum/blas/native/internal/math32" -) - -func newGeneral32(r, c int) general32 { - return general32{ - data: make([]float32, r*c), - rows: r, - cols: c, - stride: c, - } -} - -type general32 struct { - data []float32 - rows, cols int - stride int -} - -// adds element-wise into receiver. rows and columns must match -func (g general32) add(h general32) { - if debug { - if g.rows != h.rows { - panic("blas: row size mismatch") - } - if g.cols != h.cols { - panic("blas: col size mismatch") - } - } - for i := 0; i < g.rows; i++ { - gtmp := g.data[i*g.stride : i*g.stride+g.cols] - for j, v := range h.data[i*h.stride : i*h.stride+h.cols] { - gtmp[j] += v - } - } -} - -// at returns the value at the ith row and jth column. For speed reasons, the -// rows and columns are not bounds checked. -func (g general32) at(i, j int) float32 { - if debug { - if i < 0 || i >= g.rows { - panic("blas: row out of bounds") - } - if j < 0 || j >= g.cols { - panic("blas: col out of bounds") - } - } - return g.data[i*g.stride+j] -} - -func (g general32) check(c byte) error { - if g.rows < 0 { - return errors.New("blas: rows < 0") - } - if g.cols < 0 { - return errors.New("blas: cols < 0") - } - if g.stride < 1 { - return errors.New("blas: stride < 1") - } - if g.stride < g.cols { - return errors.New("blas: illegal stride") - } - if (g.rows-1)*g.stride+g.cols > len(g.data) { - return fmt.Errorf("blas: index of %c out of range", c) - } - return nil -} - -func (g general32) clone() general32 { - data := make([]float32, len(g.data)) - copy(data, g.data) - return general32{ - data: data, - rows: g.rows, - cols: g.cols, - stride: g.stride, - } -} - -// assumes they are the same size -func (g general32) copy(h general32) { - if debug { - if g.rows != h.rows { - panic("blas: row mismatch") - } - if g.cols != h.cols { - panic("blas: col mismatch") - } - } - for k := 0; k < g.rows; k++ { - copy(g.data[k*g.stride:(k+1)*g.stride], h.data[k*h.stride:(k+1)*h.stride]) - } -} - -func (g general32) equal(a general32) bool { - if g.rows != a.rows || g.cols != a.cols || g.stride != a.stride { - return false - } - for i, v := range g.data { - if a.data[i] != v { - return false - } - } - return true -} - -/* -// print is to aid debugging. Commented out to avoid fmt import -func (g general32) print() { - fmt.Println("r = ", g.rows, "c = ", g.cols, "stride: ", g.stride) - for i := 0; i < g.rows; i++ { - fmt.Println(g.data[i*g.stride : (i+1)*g.stride]) - } - -} -*/ - -func (g general32) view(i, j, r, c int) general32 { - if debug { - if i < 0 || i+r > g.rows { - panic("blas: row out of bounds") - } - if j < 0 || j+c > g.cols { - panic("blas: col out of bounds") - } - } - return general32{ - data: g.data[i*g.stride+j : (i+r-1)*g.stride+j+c], - rows: r, - cols: c, - stride: g.stride, - } -} - -func (g general32) equalWithinAbs(a general32, tol float32) bool { - if g.rows != a.rows || g.cols != a.cols || g.stride != a.stride { - return false - } - for i, v := range g.data { - if math.Abs(a.data[i]-v) > tol { - return false - } - } - return true -} diff --git a/vendor/github.com/gonum/internal/asm/f32/ddot.go b/vendor/github.com/gonum/internal/asm/f32/ddot.go deleted file mode 100644 index 6920f659..00000000 --- a/vendor/github.com/gonum/internal/asm/f32/ddot.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package f32 - -// DdotUnitary is -// for i, v := range x { -// sum += float64(y[i]) * float64(v) -// } -// return -func DdotUnitary(x, y []float32) (sum float64) { - for i, v := range x { - sum += float64(y[i]) * float64(v) - } - return -} - -// DdotInc is -// for i := 0; i < int(n); i++ { -// sum += float64(y[iy]) * float64(x[ix]) -// ix += incX -// iy += incY -// } -// return -func DdotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float64) { - for i := 0; i < int(n); i++ { - sum += float64(y[iy]) * float64(x[ix]) - ix += incX - iy += incY - } - return -} diff --git a/vendor/github.com/gonum/internal/asm/f32/dot.go b/vendor/github.com/gonum/internal/asm/f32/dot.go deleted file mode 100644 index 7a27d35e..00000000 --- a/vendor/github.com/gonum/internal/asm/f32/dot.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package f32 - -// DotUnitary is -// for i, v := range x { -// sum += y[i] * v -// } -// return sum -func DotUnitary(x, y []float32) (sum float32) { - for i, v := range x { - sum += y[i] * v - } - return sum -} - -// DotInc is -// for i := 0; i < int(n); i++ { -// sum += y[iy] * x[ix] -// ix += incX -// iy += incY -// } -// return sum -func DotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float32) { - for i := 0; i < int(n); i++ { - sum += y[iy] * x[ix] - ix += incX - iy += incY - } - return sum -} diff --git a/vendor/github.com/gonum/matrix/doc.go b/vendor/github.com/gonum/matrix/doc.go deleted file mode 100644 index c94f8df1..00000000 --- a/vendor/github.com/gonum/matrix/doc.go +++ /dev/null @@ -1,103 +0,0 @@ -// Generated by running -// go generate github.com/gonum/matrix -// DO NOT EDIT. - -// Copyright ©2015 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package matrix provides common error handling mechanisms for matrix operations -// in mat64 and cmat128. -// -// Overview -// -// This section provides a quick overview of the matrix package. The following -// sections provide more in depth commentary. -// -// matrix provides: -// - Error type definitions -// - Error recovery mechanisms -// - Common constants used by mat64 and cmat128 -// -// Errors -// -// The mat64 and cmat128 matrix packages share a common set of errors -// provided by matrix via the matrix.Error type. -// -// Errors are either returned directly or used as the parameter of a panic -// depending on the class of error encountered. Returned errors indicate -// that a call was not able to complete successfully while panics generally -// indicate a programmer or unrecoverable error. -// -// Examples of each type are found in the mat64 Solve methods, which find -// x such that A*x = b. -// -// An error value is returned from the function or method when the operation -// can meaningfully fail. The Solve operation cannot complete if A is -// singular. However, determining the singularity of A is most easily -// discovered during the Solve procedure itself and is a valid result from -// the operation, so in this case an error is returned. -// -// A function will panic when the input parameters are inappropriate for -// the function. In Solve, for example, the number of rows of each input -// matrix must be equal because of the rules of matrix multiplication. -// Similarly, for solving A*x = b, a non-zero receiver must have the same -// number of rows as A has columns and must have the same number of columns -// as b. In all cases where a function will panic, conditions that would -// lead to a panic can easily be checked prior to a call. -// -// Error Recovery -// -// When a matrix.Error is the parameter of a panic, the panic can be -// recovered by a Maybe function, which will then return the error. -// Panics that are not of type matrix.Error are re-panicked by the -// Maybe functions. -// -// Invariants -// -// Matrix input arguments to functions are never directly modified. If an operation -// changes Matrix data, the mutated matrix will be the receiver of a function. -// -// For convenience, a matrix may be used as both a receiver and as an input, e.g. -// a.Pow(a, 6) -// v.SolveVec(a.T(), v) -// though in many cases this will cause an allocation (see Element Aliasing). -// An exception to this rule is Copy, which does not allow a.Copy(a.T()). -// -// Element Aliasing -// -// Most methods in the matrix packages modify receiver data. It is forbidden for the modified -// data region of the receiver to overlap the used data area of the input -// arguments. The exception to this rule is when the method receiver is equal to one -// of the input arguments, as in the a.Pow(a, 6) call above, or its implicit transpose. -// -// This prohibition is to help avoid subtle mistakes when the method needs to read -// from and write to the same data region. There are ways to make mistakes using the -// matrix API, and matrix functions will detect and complain about those. -// There are many ways to make mistakes by excursion from the matrix API via -// interaction with raw matrix values. -// -// If you need to read the rest of this section to understand the behavior of -// your program, you are being clever. Don't be clever. If you must be clever, -// blas64/cblas128 and lapack64/clapack128 may be used to call the behavior directly. -// -// The matrix packages will use the following rules to detect overlap between the receiver and one -// of the inputs: -// - the input implements one of the Raw methods, and -// - the Raw type matches that of the receiver or -// one is a RawMatrixer and the other is a RawVectorer, and -// - the address ranges of the backing data slices overlap, and -// - the strides differ or there is an overlap in the used data elements. -// If such an overlap is detected, the method will panic. -// -// The following cases will not panic: -// - the data slices do not overlap, -// - there is pointer identity between the receiver and input values after -// the value has been untransposed if necessary. -// -// The matrix packages will not attempt to detect element overlap if the input does not implement a -// Raw method, or if the Raw method differs from that of the receiver except when a -// conversion has occurred through a matrix API function. Method behavior is undefined -// if there is undetected overlap. -// -package matrix diff --git a/vendor/github.com/gonum/matrix/gendoc.go b/vendor/github.com/gonum/matrix/gendoc.go deleted file mode 100644 index f82b6b20..00000000 --- a/vendor/github.com/gonum/matrix/gendoc.go +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//+build ignore - -// gendoc creates the matrix, mat64 and cmat128 package doc comments. -package main - -import ( - "fmt" - "log" - "os" - "path/filepath" - "strings" - "text/template" - "unicode/utf8" -) - -var docs = template.Must(template.New("docs").Funcs(funcs).Parse(`{{define "common"}}// Generated by running -// go generate github.com/gonum/matrix -// DO NOT EDIT. - -// Copyright ©2015 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package {{.Name}} provides {{.Provides}} -// -// Overview -// -// This section provides a quick overview of the {{.Name}} package. The following -// sections provide more in depth commentary. -// -{{.Overview}} -//{{end}} -{{define "interfaces"}}// The Matrix Interfaces -// -// The Matrix interface is the common link between the concrete types. The Matrix -// interface is defined by three functions: Dims, which returns the dimensions -// of the Matrix, At, which returns the element in the specified location, and -// T for returning a Transpose (discussed later). All of the concrete types can -// perform these behaviors and so implement the interface. Methods and functions -// are designed to use this interface, so in particular the method -// func (m *Dense) Mul(a, b Matrix) -// constructs a *Dense from the result of a multiplication with any Matrix types, -// not just *Dense. Where more restrictive requirements must be met, there are also the -// Symmetric and Triangular interfaces. For example, in -// func (s *SymDense) AddSym(a, b Symmetric) -// the Symmetric interface guarantees a symmetric result. -// -// Transposes -// -// The T method is used for transposition. For example, c.Mul(a.T(), b) computes -// c = a^T * b. The {{if .ExamplePackage}}{{.ExamplePackage}}{{else}}{{.Name}}{{end}} types implement this method using an implicit transpose — -// see the Transpose type for more details. Note that some operations have a -// transpose as part of their definition, as in *SymDense.SymOuterK. -//{{end}} -{{define "factorization"}}// Matrix Factorization -// -// Matrix factorizations, such as the LU decomposition, typically have their own -// specific data storage, and so are each implemented as a specific type. The -// factorization can be computed through a call to Factorize -// var lu {{if .ExamplePackage}}{{.ExamplePackage}}{{else}}{{.Name}}{{end}}.LU -// lu.Factorize(a) -// The elements of the factorization can be extracted through methods on the -// appropriate type, i.e. *TriDense.LFromLU and *TriDense.UFromLU. Alternatively, -// they can be used directly, as in *Dense.SolveLU. Some factorizations can be -// updated directly, without needing to update the original matrix and refactorize, -// as in *LU.RankOne. -//{{end}} -{{define "blas"}}// BLAS and LAPACK -// -// BLAS and LAPACK are the standard APIs for linear algebra routines. Many -// operations in {{if .Description}}{{.Description}}{{else}}{{.Name}}{{end}} are implemented using calls to the wrapper functions -// in gonum/blas/{{.BLAS|alts}} and gonum/lapack/{{.LAPACK|alts}}. By default, {{.BLAS|join "/"}} and -// {{.LAPACK|join "/"}} call the native Go implementations of the routines. Alternatively, -// it is possible to use C-based implementations of the APIs through the respective -// cgo packages and "Use" functions. The Go implementation of LAPACK makes calls -// through {{.BLAS|join "/"}}, so if a cgo BLAS implementation is registered, the {{.LAPACK|join "/"}} -// calls will be partially executed in Go and partially executed in C. -//{{end}} -{{define "switching"}}// Type Switching -// -// The Matrix abstraction enables efficiency as well as interoperability. Go's -// type reflection capabilities are used to choose the most efficient routine -// given the specific concrete types. For example, in -// c.Mul(a, b) -// if a and b both implement RawMatrixer, that is, they can be represented as a -// {{.BLAS|alts}}.General, {{.BLAS|alts}}.Gemm (general matrix multiplication) is called, while -// instead if b is a RawSymmetricer {{.BLAS|alts}}.Symm is used (general-symmetric -// multiplication), and if b is a *Vector {{.BLAS|alts}}.Gemv is used. -// -// There are many possible type combinations and special cases. No specific guarantees -// are made about the performance of any method, and in particular, note that an -// abstract matrix type may be copied into a concrete type of the corresponding -// value. If there are specific special cases that are needed, please submit a -// pull-request or file an issue. -//{{end}} -{{define "invariants"}}// Invariants -// -// Matrix input arguments to functions are never directly modified. If an operation -// changes Matrix data, the mutated matrix will be the receiver of a function. -// -// For convenience, a matrix may be used as both a receiver and as an input, e.g. -// a.Pow(a, 6) -// v.SolveVec(a.T(), v) -// though in many cases this will cause an allocation (see Element Aliasing). -// An exception to this rule is Copy, which does not allow a.Copy(a.T()). -//{{end}} -{{define "aliasing"}}// Element Aliasing -// -// Most methods in {{if .Description}}{{.Description}}{{else}}{{.Name}}{{end}} modify receiver data. It is forbidden for the modified -// data region of the receiver to overlap the used data area of the input -// arguments. The exception to this rule is when the method receiver is equal to one -// of the input arguments, as in the a.Pow(a, 6) call above, or its implicit transpose. -// -// This prohibition is to help avoid subtle mistakes when the method needs to read -// from and write to the same data region. There are ways to make mistakes using the -// {{.Name}} API, and {{.Name}} functions will detect and complain about those. -// There are many ways to make mistakes by excursion from the {{.Name}} API via -// interaction with raw matrix values. -// -// If you need to read the rest of this section to understand the behavior of -// your program, you are being clever. Don't be clever. If you must be clever, -// {{.BLAS|join "/"}} and {{.LAPACK|join "/"}} may be used to call the behavior directly. -// -// {{if .Description}}{{.Description|sentence}}{{else}}{{.Name}}{{end}} will use the following rules to detect overlap between the receiver and one -// of the inputs: -// - the input implements one of the Raw methods, and -// - the Raw type matches that of the receiver or -// one is a RawMatrixer and the other is a RawVectorer, and -// - the address ranges of the backing data slices overlap, and -// - the strides differ or there is an overlap in the used data elements. -// If such an overlap is detected, the method will panic. -// -// The following cases will not panic: -// - the data slices do not overlap, -// - there is pointer identity between the receiver and input values after -// the value has been untransposed if necessary. -// -// {{if .Description}}{{.Description|sentence}}{{else}}{{.Name}}{{end}} will not attempt to detect element overlap if the input does not implement a -// Raw method, or if the Raw method differs from that of the receiver except when a -// conversion has occurred through a {{.Name}} API function. Method behavior is undefined -// if there is undetected overlap. -//{{end}}`)) - -type Package struct { - path string - - Name string - Provides string - Description string - ExamplePackage string - Overview string - - BLAS []string - LAPACK []string - - template string -} - -var pkgs = []Package{ - { - path: ".", - - Name: "matrix", - Description: "the matrix packages", - Provides: `common error handling mechanisms for matrix operations -// in mat64 and cmat128.`, - ExamplePackage: "mat64", - - Overview: `// matrix provides: -// - Error type definitions -// - Error recovery mechanisms -// - Common constants used by mat64 and cmat128 -// -// Errors -// -// The mat64 and cmat128 matrix packages share a common set of errors -// provided by matrix via the matrix.Error type. -// -// Errors are either returned directly or used as the parameter of a panic -// depending on the class of error encountered. Returned errors indicate -// that a call was not able to complete successfully while panics generally -// indicate a programmer or unrecoverable error. -// -// Examples of each type are found in the mat64 Solve methods, which find -// x such that A*x = b. -// -// An error value is returned from the function or method when the operation -// can meaningfully fail. The Solve operation cannot complete if A is -// singular. However, determining the singularity of A is most easily -// discovered during the Solve procedure itself and is a valid result from -// the operation, so in this case an error is returned. -// -// A function will panic when the input parameters are inappropriate for -// the function. In Solve, for example, the number of rows of each input -// matrix must be equal because of the rules of matrix multiplication. -// Similarly, for solving A*x = b, a non-zero receiver must have the same -// number of rows as A has columns and must have the same number of columns -// as b. In all cases where a function will panic, conditions that would -// lead to a panic can easily be checked prior to a call. -// -// Error Recovery -// -// When a matrix.Error is the parameter of a panic, the panic can be -// recovered by a Maybe function, which will then return the error. -// Panics that are not of type matrix.Error are re-panicked by the -// Maybe functions.`, - BLAS: []string{"blas64", "cblas128"}, - LAPACK: []string{"lapack64", "clapack128"}, - - template: `{{template "common" .}} -{{template "invariants" .}} -{{template "aliasing" .}} -package {{.Name}} -`, - }, - { - path: "mat64", - - Name: "mat64", - Provides: `implementations of float64 matrix structures and -// linear algebra operations on them.`, - - Overview: `// mat64 provides: -// - Interfaces for Matrix classes (Matrix, Symmetric, Triangular) -// - Concrete implementations (Dense, SymDense, TriDense) -// - Methods and functions for using matrix data (Add, Trace, SymRankOne) -// - Types for constructing and using matrix factorizations (QR, LU) -// -// A matrix may be constructed through the corresponding New function. If no -// backing array is provided the matrix will be initialized to all zeros. -// // Allocate a zeroed matrix of size 3×5 -// zero := mat64.NewDense(3, 5, nil) -// If a backing data slice is provided, the matrix will have those elements. -// Matrices are all stored in row-major format. -// // Generate a 6×6 matrix of random values. -// data := make([]float64, 36) -// for i := range data { -// data[i] = rand.NormFloat64() -// } -// a := mat64.NewDense(6, 6, data) -// -// Operations involving matrix data are implemented as functions when the values -// of the matrix remain unchanged -// tr := mat64.Trace(a) -// and are implemented as methods when the operation modifies the receiver. -// zero.Copy(a) -// -// Receivers must be the correct size for the matrix operations, otherwise the -// operation will panic. As a special case for convenience, a zero-sized matrix -// will be modified to have the correct size, allocating data if necessary. -// var c mat64.Dense // construct a new zero-sized matrix -// c.Mul(a, a) // c is automatically adjusted to be 6×6`, - - BLAS: []string{"blas64"}, - LAPACK: []string{"lapack64"}, - - template: `{{template "common" .}} -{{template "interfaces" .}} -{{template "factorization" .}} -{{template "blas" .}} -{{template "switching" .}} -{{template "invariants" .}} -{{template "aliasing" .}} -package {{.Name}} -`, - }, - { - path: "cmat128", - - Name: "cmat128", - Provides: `implementations of complex128 matrix structures and -// linear algebra operations on them.`, - - Overview: `// cmat128 provides: -// - Interfaces for a complex Matrix`, - - BLAS: []string{"cblas128"}, - LAPACK: []string{"clapack128"}, - - template: `{{template "common" . }} -{{template "blas" .}} -{{template "switching" .}} -{{template "invariants" .}} -{{template "aliasing" .}} -package {{.Name}} -`, - }, -} - -var funcs = template.FuncMap{ - "sentence": sentence, - "alts": alts, - "join": join, -} - -// sentence converts a string to sentence case where the string is the prefix of the sentence. -func sentence(s string) string { - if len(s) == 0 { - return "" - } - _, size := utf8.DecodeRune([]byte(s)) - return strings.ToUpper(s[:size]) + s[size:] -} - -// alts renders a []string as a glob alternatives list. -func alts(s []string) string { - switch len(s) { - case 0: - return "" - case 1: - return s[0] - default: - return fmt.Sprintf("{%s}", strings.Join(s, ",")) - } -} - -// join is strings.Join with the parameter order changed. -func join(sep string, s []string) string { - return strings.Join(s, sep) -} - -func main() { - for _, pkg := range pkgs { - t, err := template.Must(docs.Clone()).Parse(pkg.template) - if err != nil { - log.Fatalf("failed to parse template: %v", err) - } - file := filepath.Join(pkg.path, "doc.go") - f, err := os.Create(file) - if err != nil { - log.Fatalf("failed to create %q: %v", file, err) - } - err = t.Execute(f, pkg) - if err != nil { - log.Fatalf("failed to execute template: %v", err) - } - f.Close() - } -} diff --git a/vendor/github.com/gonum/matrix/generate.go b/vendor/github.com/gonum/matrix/generate.go deleted file mode 100644 index 068fb261..00000000 --- a/vendor/github.com/gonum/matrix/generate.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:generate go run gendoc.go - -package matrix diff --git a/vendor/github.com/gonum/matrix/mat64/index_bound_checks.go b/vendor/github.com/gonum/matrix/mat64/index_bound_checks.go deleted file mode 100644 index 344df5e8..00000000 --- a/vendor/github.com/gonum/matrix/mat64/index_bound_checks.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright ©2014 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file must be kept in sync with index_no_bound_checks.go. - -//+build bounds - -package mat64 - -import "github.com/gonum/matrix" - -// At returns the element at row i, column j. -func (m *Dense) At(i, j int) float64 { - return m.at(i, j) -} - -func (m *Dense) at(i, j int) float64 { - if uint(i) >= uint(m.mat.Rows) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(m.mat.Cols) { - panic(matrix.ErrColAccess) - } - return m.mat.Data[i*m.mat.Stride+j] -} - -// Set sets the element at row i, column j to the value v. -func (m *Dense) Set(i, j int, v float64) { - m.set(i, j, v) -} - -func (m *Dense) set(i, j int, v float64) { - if uint(i) >= uint(m.mat.Rows) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(m.mat.Cols) { - panic(matrix.ErrColAccess) - } - m.mat.Data[i*m.mat.Stride+j] = v -} - -// At returns the element at row i. -// It panics if i is out of bounds or if j is not zero. -func (v *Vector) At(i, j int) float64 { - if j != 0 { - panic(matrix.ErrColAccess) - } - return v.at(i) -} - -func (v *Vector) at(i int) float64 { - if uint(i) >= uint(v.n) { - panic(matrix.ErrRowAccess) - } - return v.mat.Data[i*v.mat.Inc] -} - -// SetVec sets the element at row i to the value val. -// It panics if i is out of bounds. -func (v *Vector) SetVec(i int, val float64) { - v.setVec(i, val) -} - -func (v *Vector) setVec(i int, val float64) { - if uint(i) >= uint(v.n) { - panic(matrix.ErrVectorAccess) - } - v.mat.Data[i*v.mat.Inc] = val -} - -// At returns the element at row i and column j. -func (t *SymDense) At(i, j int) float64 { - return t.at(i, j) -} - -func (t *SymDense) at(i, j int) float64 { - if uint(i) >= uint(t.mat.N) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(t.mat.N) { - panic(matrix.ErrColAccess) - } - if i > j { - i, j = j, i - } - return t.mat.Data[i*t.mat.Stride+j] -} - -// SetSym sets the elements at (i,j) and (j,i) to the value v. -func (t *SymDense) SetSym(i, j int, v float64) { - t.set(i, j, v) -} - -func (t *SymDense) set(i, j int, v float64) { - if uint(i) >= uint(t.mat.N) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(t.mat.N) { - panic(matrix.ErrColAccess) - } - if i > j { - i, j = j, i - } - t.mat.Data[i*t.mat.Stride+j] = v -} - -// At returns the element at row i, column j. -func (t *TriDense) At(i, j int) float64 { - return t.at(i, j) -} - -func (t *TriDense) at(i, j int) float64 { - if uint(i) >= uint(t.mat.N) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(t.mat.N) { - panic(matrix.ErrColAccess) - } - isUpper := t.isUpper() - if (isUpper && i > j) || (!isUpper && i < j) { - return 0 - } - return t.mat.Data[i*t.mat.Stride+j] -} - -// SetTri sets the element of the triangular matrix at row i, column j to the value v. -// It panics if the location is outside the appropriate half of the matrix. -func (t *TriDense) SetTri(i, j int, v float64) { - t.set(i, j, v) -} - -func (t *TriDense) set(i, j int, v float64) { - if uint(i) >= uint(t.mat.N) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(t.mat.N) { - panic(matrix.ErrColAccess) - } - isUpper := t.isUpper() - if (isUpper && i > j) || (!isUpper && i < j) { - panic(matrix.ErrTriangleSet) - } - t.mat.Data[i*t.mat.Stride+j] = v -} diff --git a/vendor/github.com/gonum/matrix/mat64/index_no_bound_checks.go b/vendor/github.com/gonum/matrix/mat64/index_no_bound_checks.go deleted file mode 100644 index 1bb4c1ea..00000000 --- a/vendor/github.com/gonum/matrix/mat64/index_no_bound_checks.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright ©2014 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file must be kept in sync with index_bound_checks.go. - -//+build !bounds - -package mat64 - -import "github.com/gonum/matrix" - -// At returns the element at row i, column j. -func (m *Dense) At(i, j int) float64 { - if uint(i) >= uint(m.mat.Rows) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(m.mat.Cols) { - panic(matrix.ErrColAccess) - } - return m.at(i, j) -} - -func (m *Dense) at(i, j int) float64 { - return m.mat.Data[i*m.mat.Stride+j] -} - -// Set sets the element at row i, column j to the value v. -func (m *Dense) Set(i, j int, v float64) { - if uint(i) >= uint(m.mat.Rows) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(m.mat.Cols) { - panic(matrix.ErrColAccess) - } - m.set(i, j, v) -} - -func (m *Dense) set(i, j int, v float64) { - m.mat.Data[i*m.mat.Stride+j] = v -} - -// At returns the element at row i. -// It panics if i is out of bounds or if j is not zero. -func (v *Vector) At(i, j int) float64 { - if uint(i) >= uint(v.n) { - panic(matrix.ErrRowAccess) - } - if j != 0 { - panic(matrix.ErrColAccess) - } - return v.at(i) -} - -func (v *Vector) at(i int) float64 { - return v.mat.Data[i*v.mat.Inc] -} - -// SetVec sets the element at row i to the value val. -// It panics if i is out of bounds. -func (v *Vector) SetVec(i int, val float64) { - if uint(i) >= uint(v.n) { - panic(matrix.ErrVectorAccess) - } - v.setVec(i, val) -} - -func (v *Vector) setVec(i int, val float64) { - v.mat.Data[i*v.mat.Inc] = val -} - -// At returns the element at row i and column j. -func (s *SymDense) At(i, j int) float64 { - if uint(i) >= uint(s.mat.N) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(s.mat.N) { - panic(matrix.ErrColAccess) - } - return s.at(i, j) -} - -func (s *SymDense) at(i, j int) float64 { - if i > j { - i, j = j, i - } - return s.mat.Data[i*s.mat.Stride+j] -} - -// SetSym sets the elements at (i,j) and (j,i) to the value v. -func (s *SymDense) SetSym(i, j int, v float64) { - if uint(i) >= uint(s.mat.N) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(s.mat.N) { - panic(matrix.ErrColAccess) - } - s.set(i, j, v) -} - -func (s *SymDense) set(i, j int, v float64) { - if i > j { - i, j = j, i - } - s.mat.Data[i*s.mat.Stride+j] = v -} - -// At returns the element at row i, column j. -func (t *TriDense) At(i, j int) float64 { - if uint(i) >= uint(t.mat.N) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(t.mat.N) { - panic(matrix.ErrColAccess) - } - return t.at(i, j) -} - -func (t *TriDense) at(i, j int) float64 { - isUpper := t.triKind() - if (isUpper && i > j) || (!isUpper && i < j) { - return 0 - } - return t.mat.Data[i*t.mat.Stride+j] -} - -// SetTri sets the element at row i, column j to the value v. -// It panics if the location is outside the appropriate half of the matrix. -func (t *TriDense) SetTri(i, j int, v float64) { - if uint(i) >= uint(t.mat.N) { - panic(matrix.ErrRowAccess) - } - if uint(j) >= uint(t.mat.N) { - panic(matrix.ErrColAccess) - } - isUpper := t.isUpper() - if (isUpper && i > j) || (!isUpper && i < j) { - panic(matrix.ErrTriangleSet) - } - t.set(i, j, v) -} - -func (t *TriDense) set(i, j int, v float64) { - t.mat.Data[i*t.mat.Stride+j] = v -} diff --git a/vendor/github.com/gonum/matrix/mat64/inner.go b/vendor/github.com/gonum/matrix/mat64/inner.go deleted file mode 100644 index a003a1f4..00000000 --- a/vendor/github.com/gonum/matrix/mat64/inner.go +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright ©2014 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package mat64 - -import ( - "github.com/gonum/blas" - "github.com/gonum/internal/asm/f64" - "github.com/gonum/matrix" -) - -// Inner computes the generalized inner product -// x^T A y -// between vectors x and y with matrix A. This is only a true inner product if -// A is symmetric positive definite, though the operation works for any matrix A. -// -// Inner panics if x.Len != m or y.Len != n when A is an m x n matrix. -func Inner(x *Vector, A Matrix, y *Vector) float64 { - m, n := A.Dims() - if x.Len() != m { - panic(matrix.ErrShape) - } - if y.Len() != n { - panic(matrix.ErrShape) - } - if m == 0 || n == 0 { - return 0 - } - - var sum float64 - - switch b := A.(type) { - case RawSymmetricer: - bmat := b.RawSymmetric() - if bmat.Uplo != blas.Upper { - // Panic as a string not a mat64.Error. - panic(badSymTriangle) - } - for i := 0; i < x.Len(); i++ { - xi := x.at(i) - if xi != 0 { - if y.mat.Inc == 1 { - sum += xi * f64.DotUnitary( - bmat.Data[i*bmat.Stride+i:i*bmat.Stride+n], - y.mat.Data[i:], - ) - } else { - sum += xi * f64.DotInc( - bmat.Data[i*bmat.Stride+i:i*bmat.Stride+n], - y.mat.Data[i*y.mat.Inc:], uintptr(n-i), - 1, uintptr(y.mat.Inc), - 0, 0, - ) - } - } - yi := y.at(i) - if i != n-1 && yi != 0 { - if x.mat.Inc == 1 { - sum += yi * f64.DotUnitary( - bmat.Data[i*bmat.Stride+i+1:i*bmat.Stride+n], - x.mat.Data[i+1:], - ) - } else { - sum += yi * f64.DotInc( - bmat.Data[i*bmat.Stride+i+1:i*bmat.Stride+n], - x.mat.Data[(i+1)*x.mat.Inc:], uintptr(n-i-1), - 1, uintptr(x.mat.Inc), - 0, 0, - ) - } - } - } - case RawMatrixer: - bmat := b.RawMatrix() - for i := 0; i < x.Len(); i++ { - xi := x.at(i) - if xi != 0 { - if y.mat.Inc == 1 { - sum += xi * f64.DotUnitary( - bmat.Data[i*bmat.Stride:i*bmat.Stride+n], - y.mat.Data, - ) - } else { - sum += xi * f64.DotInc( - bmat.Data[i*bmat.Stride:i*bmat.Stride+n], - y.mat.Data, uintptr(n), - 1, uintptr(y.mat.Inc), - 0, 0, - ) - } - } - } - default: - for i := 0; i < x.Len(); i++ { - xi := x.at(i) - for j := 0; j < y.Len(); j++ { - sum += xi * A.At(i, j) * y.at(j) - } - } - } - return sum -} diff --git a/vendor/github.com/gonum/matrix/mat64/lq.go b/vendor/github.com/gonum/matrix/mat64/lq.go deleted file mode 100644 index b3511362..00000000 --- a/vendor/github.com/gonum/matrix/mat64/lq.go +++ /dev/null @@ -1,217 +0,0 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package mat64 - -import ( - "math" - - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" -) - -// LQ is a type for creating and using the LQ factorization of a matrix. -type LQ struct { - lq *Dense - tau []float64 - cond float64 -} - -func (lq *LQ) updateCond() { - // A = LQ, where Q is orthonormal. Orthonormal multiplications do not change - // the condition number. Thus, ||A|| = ||L|| ||Q|| = ||Q||. - m := lq.lq.mat.Rows - work := make([]float64, 3*m) - iwork := make([]int, m) - l := lq.lq.asTriDense(m, blas.NonUnit, blas.Lower) - v := lapack64.Trcon(matrix.CondNorm, l.mat, work, iwork) - lq.cond = 1 / v -} - -// Factorize computes the LQ factorization of an m×n matrix a where n <= m. The LQ -// factorization always exists even if A is singular. -// -// The LQ decomposition is a factorization of the matrix A such that A = L * Q. -// The matrix Q is an orthonormal n×n matrix, and L is an m×n upper triangular matrix. -// L and Q can be extracted from the LFromLQ and QFromLQ methods on Dense. -func (lq *LQ) Factorize(a Matrix) { - m, n := a.Dims() - if m > n { - panic(matrix.ErrShape) - } - k := min(m, n) - if lq.lq == nil { - lq.lq = &Dense{} - } - lq.lq.Clone(a) - work := make([]float64, 1) - lq.tau = make([]float64, k) - lapack64.Gelqf(lq.lq.mat, lq.tau, work, -1) - work = make([]float64, int(work[0])) - lapack64.Gelqf(lq.lq.mat, lq.tau, work, len(work)) - lq.updateCond() -} - -// TODO(btracey): Add in the "Reduced" forms for extracting the m×m orthogonal -// and upper triangular matrices. - -// LFromLQ extracts the m×n lower trapezoidal matrix from a LQ decomposition. -func (m *Dense) LFromLQ(lq *LQ) { - r, c := lq.lq.Dims() - m.reuseAs(r, c) - - // Disguise the LQ as a lower triangular - t := &TriDense{ - mat: blas64.Triangular{ - N: r, - Stride: lq.lq.mat.Stride, - Data: lq.lq.mat.Data, - Uplo: blas.Lower, - Diag: blas.NonUnit, - }, - cap: lq.lq.capCols, - } - m.Copy(t) - - if r == c { - return - } - // Zero right of the triangular. - for i := 0; i < r; i++ { - zero(m.mat.Data[i*m.mat.Stride+r : i*m.mat.Stride+c]) - } -} - -// QFromLQ extracts the n×n orthonormal matrix Q from an LQ decomposition. -func (m *Dense) QFromLQ(lq *LQ) { - r, c := lq.lq.Dims() - m.reuseAs(c, c) - - // Set Q = I. - for i := 0; i < c; i++ { - v := m.mat.Data[i*m.mat.Stride : i*m.mat.Stride+c] - zero(v) - v[i] = 1 - } - - // Construct Q from the elementary reflectors. - h := blas64.General{ - Rows: c, - Cols: c, - Stride: c, - Data: make([]float64, c*c), - } - qCopy := getWorkspace(c, c, false) - v := blas64.Vector{ - Inc: 1, - Data: make([]float64, c), - } - for i := 0; i < r; i++ { - // Set h = I. - zero(h.Data) - for j := 0; j < len(h.Data); j += c + 1 { - h.Data[j] = 1 - } - - // Set the vector data as the elementary reflector. - for j := 0; j < i; j++ { - v.Data[j] = 0 - } - v.Data[i] = 1 - for j := i + 1; j < c; j++ { - v.Data[j] = lq.lq.mat.Data[i*lq.lq.mat.Stride+j] - } - - // Compute the multiplication matrix. - blas64.Ger(-lq.tau[i], v, v, h) - qCopy.Copy(m) - blas64.Gemm(blas.NoTrans, blas.NoTrans, - 1, h, qCopy.mat, - 0, m.mat) - } -} - -// SolveLQ finds a minimum-norm solution to a system of linear equations defined -// by the matrices A and b, where A is an m×n matrix represented in its LQ factorized -// form. If A is singular or near-singular a Condition error is returned. Please -// see the documentation for Condition for more information. -// -// The minimization problem solved depends on the input parameters. -// If trans == false, find the minimum norm solution of A * X = b. -// If trans == true, find X such that ||A*X - b||_2 is minimized. -// The solution matrix, X, is stored in place into the receiver. -func (m *Dense) SolveLQ(lq *LQ, trans bool, b Matrix) error { - r, c := lq.lq.Dims() - br, bc := b.Dims() - - // The LQ solve algorithm stores the result in-place into the right hand side. - // The storage for the answer must be large enough to hold both b and x. - // However, this method's receiver must be the size of x. Copy b, and then - // copy the result into m at the end. - if trans { - if c != br { - panic(matrix.ErrShape) - } - m.reuseAs(r, bc) - } else { - if r != br { - panic(matrix.ErrShape) - } - m.reuseAs(c, bc) - } - // Do not need to worry about overlap between m and b because x has its own - // independent storage. - x := getWorkspace(max(r, c), bc, false) - x.Copy(b) - t := lq.lq.asTriDense(lq.lq.mat.Rows, blas.NonUnit, blas.Lower).mat - if trans { - work := make([]float64, 1) - lapack64.Ormlq(blas.Left, blas.NoTrans, lq.lq.mat, lq.tau, x.mat, work, -1) - work = make([]float64, int(work[0])) - lapack64.Ormlq(blas.Left, blas.NoTrans, lq.lq.mat, lq.tau, x.mat, work, len(work)) - - ok := lapack64.Trtrs(blas.Trans, t, x.mat) - if !ok { - return matrix.Condition(math.Inf(1)) - } - } else { - ok := lapack64.Trtrs(blas.NoTrans, t, x.mat) - if !ok { - return matrix.Condition(math.Inf(1)) - } - for i := r; i < c; i++ { - zero(x.mat.Data[i*x.mat.Stride : i*x.mat.Stride+bc]) - } - work := make([]float64, 1) - lapack64.Ormlq(blas.Left, blas.Trans, lq.lq.mat, lq.tau, x.mat, work, -1) - work = make([]float64, int(work[0])) - lapack64.Ormlq(blas.Left, blas.Trans, lq.lq.mat, lq.tau, x.mat, work, len(work)) - } - // M was set above to be the correct size for the result. - m.Copy(x) - putWorkspace(x) - if lq.cond > matrix.ConditionTolerance { - return matrix.Condition(lq.cond) - } - return nil -} - -// SolveLQVec finds a minimum-norm solution to a system of linear equations. -// Please see Dense.SolveLQ for the full documentation. -func (v *Vector) SolveLQVec(lq *LQ, trans bool, b *Vector) error { - if v != b { - v.checkOverlap(b.mat) - } - r, c := lq.lq.Dims() - // The Solve implementation is non-trivial, so rather than duplicate the code, - // instead recast the Vectors as Dense and call the matrix code. - if trans { - v.reuseAs(r) - } else { - v.reuseAs(c) - } - return v.asDense().SolveLQ(lq, trans, b.asDense()) -} diff --git a/vendor/github.com/gonum/matrix/mat64/qr.go b/vendor/github.com/gonum/matrix/mat64/qr.go deleted file mode 100644 index 7f3d565c..00000000 --- a/vendor/github.com/gonum/matrix/mat64/qr.go +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package mat64 - -import ( - "math" - - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" -) - -// QR is a type for creating and using the QR factorization of a matrix. -type QR struct { - qr *Dense - tau []float64 - cond float64 -} - -func (qr *QR) updateCond() { - // A = QR, where Q is orthonormal. Orthonormal multiplications do not change - // the condition number. Thus, ||A|| = ||Q|| ||R|| = ||R||. - n := qr.qr.mat.Cols - work := make([]float64, 3*n) - iwork := make([]int, n) - r := qr.qr.asTriDense(n, blas.NonUnit, blas.Upper) - v := lapack64.Trcon(matrix.CondNorm, r.mat, work, iwork) - qr.cond = 1 / v -} - -// Factorize computes the QR factorization of an m×n matrix a where m >= n. The QR -// factorization always exists even if A is singular. -// -// The QR decomposition is a factorization of the matrix A such that A = Q * R. -// The matrix Q is an orthonormal m×m matrix, and R is an m×n upper triangular matrix. -// Q and R can be extracted from the QFromQR and RFromQR methods on Dense. -func (qr *QR) Factorize(a Matrix) { - m, n := a.Dims() - if m < n { - panic(matrix.ErrShape) - } - k := min(m, n) - if qr.qr == nil { - qr.qr = &Dense{} - } - qr.qr.Clone(a) - work := make([]float64, 1) - qr.tau = make([]float64, k) - lapack64.Geqrf(qr.qr.mat, qr.tau, work, -1) - - work = make([]float64, int(work[0])) - lapack64.Geqrf(qr.qr.mat, qr.tau, work, len(work)) - qr.updateCond() -} - -// TODO(btracey): Add in the "Reduced" forms for extracting the n×n orthogonal -// and upper triangular matrices. - -// RFromQR extracts the m×n upper trapezoidal matrix from a QR decomposition. -func (m *Dense) RFromQR(qr *QR) { - r, c := qr.qr.Dims() - m.reuseAs(r, c) - - // Disguise the QR as an upper triangular - t := &TriDense{ - mat: blas64.Triangular{ - N: c, - Stride: qr.qr.mat.Stride, - Data: qr.qr.mat.Data, - Uplo: blas.Upper, - Diag: blas.NonUnit, - }, - cap: qr.qr.capCols, - } - m.Copy(t) - - // Zero below the triangular. - for i := r; i < c; i++ { - zero(m.mat.Data[i*m.mat.Stride : i*m.mat.Stride+c]) - } -} - -// QFromQR extracts the m×m orthonormal matrix Q from a QR decomposition. -func (m *Dense) QFromQR(qr *QR) { - r, _ := qr.qr.Dims() - m.reuseAsZeroed(r, r) - - // Set Q = I. - for i := 0; i < r*r; i += r + 1 { - m.mat.Data[i] = 1 - } - - // Construct Q from the elementary reflectors. - work := make([]float64, 1) - lapack64.Ormqr(blas.Left, blas.NoTrans, qr.qr.mat, qr.tau, m.mat, work, -1) - work = make([]float64, int(work[0])) - lapack64.Ormqr(blas.Left, blas.NoTrans, qr.qr.mat, qr.tau, m.mat, work, len(work)) -} - -// SolveQR finds a minimum-norm solution to a system of linear equations defined -// by the matrices A and b, where A is an m×n matrix represented in its QR factorized -// form. If A is singular or near-singular a Condition error is returned. Please -// see the documentation for Condition for more information. -// -// The minimization problem solved depends on the input parameters. -// If trans == false, find X such that ||A*X - b||_2 is minimized. -// If trans == true, find the minimum norm solution of A^T * X = b. -// The solution matrix, X, is stored in place into the receiver. -func (m *Dense) SolveQR(qr *QR, trans bool, b Matrix) error { - r, c := qr.qr.Dims() - br, bc := b.Dims() - - // The QR solve algorithm stores the result in-place into the right hand side. - // The storage for the answer must be large enough to hold both b and x. - // However, this method's receiver must be the size of x. Copy b, and then - // copy the result into m at the end. - if trans { - if c != br { - panic(matrix.ErrShape) - } - m.reuseAs(r, bc) - } else { - if r != br { - panic(matrix.ErrShape) - } - m.reuseAs(c, bc) - } - // Do not need to worry about overlap between m and b because x has its own - // independent storage. - x := getWorkspace(max(r, c), bc, false) - x.Copy(b) - t := qr.qr.asTriDense(qr.qr.mat.Cols, blas.NonUnit, blas.Upper).mat - if trans { - ok := lapack64.Trtrs(blas.Trans, t, x.mat) - if !ok { - return matrix.Condition(math.Inf(1)) - } - for i := c; i < r; i++ { - zero(x.mat.Data[i*x.mat.Stride : i*x.mat.Stride+bc]) - } - work := make([]float64, 1) - lapack64.Ormqr(blas.Left, blas.NoTrans, qr.qr.mat, qr.tau, x.mat, work, -1) - work = make([]float64, int(work[0])) - lapack64.Ormqr(blas.Left, blas.NoTrans, qr.qr.mat, qr.tau, x.mat, work, len(work)) - } else { - work := make([]float64, 1) - lapack64.Ormqr(blas.Left, blas.Trans, qr.qr.mat, qr.tau, x.mat, work, -1) - work = make([]float64, int(work[0])) - lapack64.Ormqr(blas.Left, blas.Trans, qr.qr.mat, qr.tau, x.mat, work, len(work)) - - ok := lapack64.Trtrs(blas.NoTrans, t, x.mat) - if !ok { - return matrix.Condition(math.Inf(1)) - } - } - // M was set above to be the correct size for the result. - m.Copy(x) - putWorkspace(x) - if qr.cond > matrix.ConditionTolerance { - return matrix.Condition(qr.cond) - } - return nil -} - -// SolveQRVec finds a minimum-norm solution to a system of linear equations. -// Please see Dense.SolveQR for the full documentation. -func (v *Vector) SolveQRVec(qr *QR, trans bool, b *Vector) error { - if v != b { - v.checkOverlap(b.mat) - } - r, c := qr.qr.Dims() - // The Solve implementation is non-trivial, so rather than duplicate the code, - // instead recast the Vectors as Dense and call the matrix code. - if trans { - v.reuseAs(r) - } else { - v.reuseAs(c) - } - return v.asDense().SolveQR(qr, trans, b.asDense()) -} diff --git a/vendor/github.com/gonum/matrix/mat64/shadow.go b/vendor/github.com/gonum/matrix/mat64/shadow.go deleted file mode 100644 index b293c63c..00000000 --- a/vendor/github.com/gonum/matrix/mat64/shadow.go +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package mat64 - -import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" -) - -const ( - // regionOverlap is the panic string used for the general case - // of a matrix region overlap between a source and destination. - regionOverlap = "mat64: bad region: overlap" - - // regionIdentity is the panic string used for the specific - // case of complete agreement between a source and a destination. - regionIdentity = "mat64: bad region: identical" - - // mismatchedStrides is the panic string used for overlapping - // data slices with differing strides. - mismatchedStrides = "mat64: bad region: different strides" -) - -// checkOverlap returns false if the receiver does not overlap data elements -// referenced by the parameter and panics otherwise. -// -// checkOverlap methods return a boolean to allow the check call to be added to a -// boolean expression, making use of short-circuit operators. - -func (m *Dense) checkOverlap(a blas64.General) bool { - mat := m.RawMatrix() - if cap(mat.Data) == 0 || cap(a.Data) == 0 { - return false - } - - off := offset(mat.Data[:1], a.Data[:1]) - - if off == 0 { - // At least one element overlaps. - if mat.Cols == a.Cols && mat.Rows == a.Rows && mat.Stride == a.Stride { - panic(regionIdentity) - } - panic(regionOverlap) - } - - if off > 0 && len(mat.Data) <= off { - // We know m is completely before a. - return false - } - if off < 0 && len(a.Data) <= -off { - // We know m is completely after a. - return false - } - - if mat.Stride != a.Stride { - // Too hard, so assume the worst. - panic(mismatchedStrides) - } - - if off < 0 { - off = -off - mat.Cols, a.Cols = a.Cols, mat.Cols - } - if rectanglesOverlap(off, mat.Cols, a.Cols, mat.Stride) { - panic(regionOverlap) - } - return false -} - -func (s *SymDense) checkOverlap(a blas64.Symmetric) bool { - mat := s.RawSymmetric() - if cap(mat.Data) == 0 || cap(a.Data) == 0 { - return false - } - - off := offset(mat.Data[:1], a.Data[:1]) - - if off == 0 { - // At least one element overlaps. - if mat.N == a.N && mat.Stride == a.Stride { - panic(regionIdentity) - } - panic(regionOverlap) - } - - if off > 0 && len(mat.Data) <= off { - // We know s is completely before a. - return false - } - if off < 0 && len(a.Data) <= -off { - // We know s is completely after a. - return false - } - - if mat.Stride != a.Stride { - // Too hard, so assume the worst. - panic(mismatchedStrides) - } - - if off < 0 { - off = -off - mat.N, a.N = a.N, mat.N - // If we created the matrix it will always - // be in the upper triangle, but don't trust - // that this is the case. - mat.Uplo, a.Uplo = a.Uplo, mat.Uplo - } - if trianglesOverlap(off, mat.N, a.N, mat.Stride, mat.Uplo == blas.Upper, a.Uplo == blas.Upper) { - panic(regionOverlap) - } - return false -} - -func (t *TriDense) checkOverlap(a blas64.Triangular) bool { - mat := t.RawTriangular() - if cap(mat.Data) == 0 || cap(a.Data) == 0 { - return false - } - - off := offset(mat.Data[:1], a.Data[:1]) - - if off == 0 { - // At least one element overlaps. - if mat.N == a.N && mat.Stride == a.Stride { - panic(regionIdentity) - } - panic(regionOverlap) - } - - if off > 0 && len(mat.Data) <= off { - // We know t is completely before a. - return false - } - if off < 0 && len(a.Data) <= -off { - // We know t is completely after a. - return false - } - - if mat.Stride != a.Stride { - // Too hard, so assume the worst. - panic(mismatchedStrides) - } - - if off < 0 { - off = -off - mat.N, a.N = a.N, mat.N - mat.Uplo, a.Uplo = a.Uplo, mat.Uplo - } - if trianglesOverlap(off, mat.N, a.N, mat.Stride, mat.Uplo == blas.Upper, a.Uplo == blas.Upper) { - panic(regionOverlap) - } - return false -} - -func (v *Vector) checkOverlap(a blas64.Vector) bool { - mat := v.mat - if cap(mat.Data) == 0 || cap(a.Data) == 0 { - return false - } - - off := offset(mat.Data[:1], a.Data[:1]) - - if off == 0 { - // At least one element overlaps. - if mat.Inc == a.Inc && len(mat.Data) == len(a.Data) { - panic(regionIdentity) - } - panic(regionOverlap) - } - - if off > 0 && len(mat.Data) <= off { - // We know v is completely before a. - return false - } - if off < 0 && len(a.Data) <= -off { - // We know v is completely after a. - return false - } - - if mat.Inc != a.Inc { - // Too hard, so assume the worst. - panic(mismatchedStrides) - } - - if mat.Inc == 1 || off&mat.Inc == 0 { - panic(regionOverlap) - } - return false -} - -// rectanglesOverlap returns whether the strided rectangles a and b overlap -// when b is offset by off elements after a but has at least one element before -// the end of a. off must be positive. a and b have aCols and bCols respectively. -// -// rectanglesOverlap works by shifting both matrices left such that the left -// column of a is at 0. The column indexes are flattened by obtaining the shifted -// relative left and right column positions modulo the common stride. This allows -// direct comparison of the column offsets when the matrix backing data slices -// are known to overlap. -func rectanglesOverlap(off, aCols, bCols, stride int) bool { - if stride == 1 { - // Unit stride means overlapping data - // slices must overlap as matrices. - return true - } - - // Flatten the shifted matrix column positions - // so a starts at 0, modulo the common stride. - const aFrom = 0 - aTo := aCols - // The mod stride operations here make the from - // and to indexes comparable between a and b when - // the data slices of a and b overlap. - bFrom := off % stride - bTo := (bFrom + bCols) % stride - - if bTo == 0 || bFrom < bTo { - // b matrix is not wrapped: compare for - // simple overlap. - return bFrom < aTo - } - - // b strictly wraps and so must overlap with a. - return true -} - -// trianglesOverlap returns whether the strided triangles a and b overlap -// when b is offset by off elements after a but has at least one element before -// the end of a. off must be positive. a and b are aSize×aSize and bSize×bSize -// respectively. -func trianglesOverlap(off, aSize, bSize, stride int, aUpper, bUpper bool) bool { - if !rectanglesOverlap(off, aSize, bSize, stride) { - // Fast return if bounding rectangles do not overlap. - return false - } - - // Find location of b relative to a. - rowOffset := off / stride - colOffset := off % stride - if (off+bSize)%stride < colOffset { - // We have wrapped, so readjust offsets. - rowOffset++ - colOffset -= stride - } - - if aUpper { - // Check whether the upper left of b - // is in the triangle of a - if rowOffset >= 0 && rowOffset <= colOffset { - return true - } - // Check whether the upper right of b - // is in the triangle of a. - return bUpper && rowOffset < colOffset+bSize - } - - // Check whether the upper left of b - // is in the triangle of a - if colOffset >= 0 && rowOffset >= colOffset { - return true - } - if bUpper { - // Check whether the upper right corner of b - // is in a or the upper row of b spans a row - // of a. - return rowOffset > colOffset+bSize || colOffset < 0 - } - if colOffset < 0 { - // Check whether the lower left of a - // is in the triangle of b or below - // the diagonal of a. This requires a - // swap of reference origin. - return -rowOffset+aSize > -colOffset - } - // Check whether the lower left of b - // is in the triangle of a or below - // the diagonal of a. - return rowOffset+bSize > colOffset -} diff --git a/vendor/github.com/gonum/matrix/mat64/vector.go b/vendor/github.com/gonum/matrix/mat64/vector.go deleted file mode 100644 index 2502fe47..00000000 --- a/vendor/github.com/gonum/matrix/mat64/vector.go +++ /dev/null @@ -1,468 +0,0 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package mat64 - -import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/internal/asm/f64" - "github.com/gonum/matrix" -) - -var ( - vector *Vector - - _ Matrix = vector - - _ Reseter = vector -) - -// Vector represents a column vector. -type Vector struct { - mat blas64.Vector - n int - // A BLAS vector can have a negative increment, but allowing this - // in the mat64 type complicates a lot of code, and doesn't gain anything. - // Vector must have positive increment in this package. -} - -// NewVector creates a new Vector of length n. If data == nil, -// a new slice is allocated for the backing slice. If len(data) == n, data is -// used as the backing slice, and changes to the elements of the returned Vector -// will be reflected in data. If neither of these is true, NewVector will panic. -func NewVector(n int, data []float64) *Vector { - if len(data) != n && data != nil { - panic(matrix.ErrShape) - } - if data == nil { - data = make([]float64, n) - } - return &Vector{ - mat: blas64.Vector{ - Inc: 1, - Data: data, - }, - n: n, - } -} - -// ViewVec returns a sub-vector view of the receiver starting at element i and -// extending n rows. If i is out of range, n is zero, or the view extends -// beyond the bounds of the Vector, ViewVec will panic with ErrIndexOutOfRange. -// The returned Vector retains reference to the underlying vector. -// -// ViewVec is deprecated and should not be used. It will be removed at a later date. -func (v *Vector) ViewVec(i, n int) *Vector { - return v.SliceVec(i, i+n) -} - -// SliceVec returns a new Vector that shares backing data with the receiver. -// The returned matrix starts at i of the recevier and extends k-i elements. -// SliceVec panics with ErrIndexOutOfRange if the slice is outside the bounds -// of the receiver. -func (v *Vector) SliceVec(i, k int) *Vector { - if i < 0 || k <= i || v.n < k { - panic(matrix.ErrIndexOutOfRange) - } - return &Vector{ - n: k - i, - mat: blas64.Vector{ - Inc: v.mat.Inc, - Data: v.mat.Data[i*v.mat.Inc : (k-1)*v.mat.Inc+1], - }, - } -} - -func (v *Vector) Dims() (r, c int) { - if v.isZero() { - return 0, 0 - } - return v.n, 1 -} - -// Len returns the length of the vector. -func (v *Vector) Len() int { - return v.n -} - -// T performs an implicit transpose by returning the receiver inside a Transpose. -func (v *Vector) T() Matrix { - return Transpose{v} -} - -// Reset zeros the length of the vector so that it can be reused as the -// receiver of a dimensionally restricted operation. -// -// See the Reseter interface for more information. -func (v *Vector) Reset() { - // No change of Inc or n to 0 may be - // made unless both are set to 0. - v.mat.Inc = 0 - v.n = 0 - v.mat.Data = v.mat.Data[:0] -} - -// CloneVec makes a copy of a into the receiver, overwriting the previous value -// of the receiver. -func (v *Vector) CloneVec(a *Vector) { - if v == a { - return - } - v.n = a.n - v.mat = blas64.Vector{ - Inc: 1, - Data: use(v.mat.Data, v.n), - } - blas64.Copy(v.n, a.mat, v.mat) -} - -func (v *Vector) RawVector() blas64.Vector { - return v.mat -} - -// CopyVec makes a copy of elements of a into the receiver. It is similar to the -// built-in copy; it copies as much as the overlap between the two vectors and -// returns the number of elements it copied. -func (v *Vector) CopyVec(a *Vector) int { - n := min(v.Len(), a.Len()) - if v != a { - blas64.Copy(n, a.mat, v.mat) - } - return n -} - -// ScaleVec scales the vector a by alpha, placing the result in the receiver. -func (v *Vector) ScaleVec(alpha float64, a *Vector) { - n := a.Len() - if v != a { - v.reuseAs(n) - if v.mat.Inc == 1 && a.mat.Inc == 1 { - f64.ScalUnitaryTo(v.mat.Data, alpha, a.mat.Data) - return - } - f64.ScalIncTo(v.mat.Data, uintptr(v.mat.Inc), - alpha, a.mat.Data, uintptr(n), uintptr(a.mat.Inc)) - return - } - if v.mat.Inc == 1 { - f64.ScalUnitary(alpha, v.mat.Data) - return - } - f64.ScalInc(alpha, v.mat.Data, uintptr(n), uintptr(v.mat.Inc)) -} - -// AddScaledVec adds the vectors a and alpha*b, placing the result in the receiver. -func (v *Vector) AddScaledVec(a *Vector, alpha float64, b *Vector) { - if alpha == 1 { - v.AddVec(a, b) - return - } - if alpha == -1 { - v.SubVec(a, b) - return - } - - ar := a.Len() - br := b.Len() - - if ar != br { - panic(matrix.ErrShape) - } - - if v != a { - v.checkOverlap(a.mat) - } - if v != b { - v.checkOverlap(b.mat) - } - - v.reuseAs(ar) - - switch { - case alpha == 0: // v <- a - v.CopyVec(a) - case v == a && v == b: // v <- v + alpha * v = (alpha + 1) * v - blas64.Scal(ar, alpha+1, v.mat) - case v == a && v != b: // v <- v + alpha * b - if v.mat.Inc == 1 && b.mat.Inc == 1 { - // Fast path for a common case. - f64.AxpyUnitaryTo(v.mat.Data, alpha, b.mat.Data, a.mat.Data) - } else { - f64.AxpyInc(alpha, b.mat.Data, v.mat.Data, - uintptr(ar), uintptr(b.mat.Inc), uintptr(v.mat.Inc), 0, 0) - } - default: // v <- a + alpha * b or v <- a + alpha * v - if v.mat.Inc == 1 && a.mat.Inc == 1 && b.mat.Inc == 1 { - // Fast path for a common case. - f64.AxpyUnitaryTo(v.mat.Data, alpha, b.mat.Data, a.mat.Data) - } else { - f64.AxpyIncTo(v.mat.Data, uintptr(v.mat.Inc), 0, - alpha, b.mat.Data, a.mat.Data, - uintptr(ar), uintptr(b.mat.Inc), uintptr(a.mat.Inc), 0, 0) - } - } -} - -// AddVec adds the vectors a and b, placing the result in the receiver. -func (v *Vector) AddVec(a, b *Vector) { - ar := a.Len() - br := b.Len() - - if ar != br { - panic(matrix.ErrShape) - } - - if v != a { - v.checkOverlap(a.mat) - } - if v != b { - v.checkOverlap(b.mat) - } - - v.reuseAs(ar) - - if v.mat.Inc == 1 && a.mat.Inc == 1 && b.mat.Inc == 1 { - // Fast path for a common case. - f64.AxpyUnitaryTo(v.mat.Data, 1, b.mat.Data, a.mat.Data) - return - } - f64.AxpyIncTo(v.mat.Data, uintptr(v.mat.Inc), 0, - 1, b.mat.Data, a.mat.Data, - uintptr(ar), uintptr(b.mat.Inc), uintptr(a.mat.Inc), 0, 0) -} - -// SubVec subtracts the vector b from a, placing the result in the receiver. -func (v *Vector) SubVec(a, b *Vector) { - ar := a.Len() - br := b.Len() - - if ar != br { - panic(matrix.ErrShape) - } - - if v != a { - v.checkOverlap(a.mat) - } - if v != b { - v.checkOverlap(b.mat) - } - - v.reuseAs(ar) - - if v.mat.Inc == 1 && a.mat.Inc == 1 && b.mat.Inc == 1 { - // Fast path for a common case. - f64.AxpyUnitaryTo(v.mat.Data, -1, b.mat.Data, a.mat.Data) - return - } - f64.AxpyIncTo(v.mat.Data, uintptr(v.mat.Inc), 0, - -1, b.mat.Data, a.mat.Data, - uintptr(ar), uintptr(b.mat.Inc), uintptr(a.mat.Inc), 0, 0) -} - -// MulElemVec performs element-wise multiplication of a and b, placing the result -// in the receiver. -func (v *Vector) MulElemVec(a, b *Vector) { - ar := a.Len() - br := b.Len() - - if ar != br { - panic(matrix.ErrShape) - } - - if v != a { - v.checkOverlap(a.mat) - } - if v != b { - v.checkOverlap(b.mat) - } - - v.reuseAs(ar) - - amat, bmat := a.RawVector(), b.RawVector() - for i := 0; i < v.n; i++ { - v.mat.Data[i*v.mat.Inc] = amat.Data[i*amat.Inc] * bmat.Data[i*bmat.Inc] - } -} - -// DivElemVec performs element-wise division of a by b, placing the result -// in the receiver. -func (v *Vector) DivElemVec(a, b *Vector) { - ar := a.Len() - br := b.Len() - - if ar != br { - panic(matrix.ErrShape) - } - - if v != a { - v.checkOverlap(a.mat) - } - if v != b { - v.checkOverlap(b.mat) - } - - v.reuseAs(ar) - - amat, bmat := a.RawVector(), b.RawVector() - for i := 0; i < v.n; i++ { - v.mat.Data[i*v.mat.Inc] = amat.Data[i*amat.Inc] / bmat.Data[i*bmat.Inc] - } -} - -// MulVec computes a * b. The result is stored into the receiver. -// MulVec panics if the number of columns in a does not equal the number of rows in b. -func (v *Vector) MulVec(a Matrix, b *Vector) { - r, c := a.Dims() - br := b.Len() - if c != br { - panic(matrix.ErrShape) - } - - if v != b { - v.checkOverlap(b.mat) - } - - a, trans := untranspose(a) - ar, ac := a.Dims() - v.reuseAs(r) - var restore func() - if v == a { - v, restore = v.isolatedWorkspace(a.(*Vector)) - defer restore() - } else if v == b { - v, restore = v.isolatedWorkspace(b) - defer restore() - } - - switch a := a.(type) { - case *Vector: - if v != a { - v.checkOverlap(a.mat) - } - - if a.Len() == 1 { - // {1,1} x {1,n} - av := a.At(0, 0) - for i := 0; i < b.Len(); i++ { - v.mat.Data[i*v.mat.Inc] = av * b.mat.Data[i*b.mat.Inc] - } - return - } - if b.Len() == 1 { - // {1,n} x {1,1} - bv := b.At(0, 0) - for i := 0; i < a.Len(); i++ { - v.mat.Data[i*v.mat.Inc] = bv * a.mat.Data[i*a.mat.Inc] - } - return - } - // {n,1} x {1,n} - var sum float64 - for i := 0; i < c; i++ { - sum += a.At(i, 0) * b.At(i, 0) - } - v.SetVec(0, sum) - return - case RawSymmetricer: - amat := a.RawSymmetric() - blas64.Symv(1, amat, b.mat, 0, v.mat) - case RawTriangular: - v.CopyVec(b) - amat := a.RawTriangular() - ta := blas.NoTrans - if trans { - ta = blas.Trans - } - blas64.Trmv(ta, amat, v.mat) - case RawMatrixer: - amat := a.RawMatrix() - // We don't know that a is a *Dense, so make - // a temporary Dense to check overlap. - (&Dense{mat: amat}).checkOverlap(v.asGeneral()) - t := blas.NoTrans - if trans { - t = blas.Trans - } - blas64.Gemv(t, 1, amat, b.mat, 0, v.mat) - default: - if trans { - col := make([]float64, ar) - for c := 0; c < ac; c++ { - for i := range col { - col[i] = a.At(i, c) - } - var f float64 - for i, e := range col { - f += e * b.mat.Data[i*b.mat.Inc] - } - v.mat.Data[c*v.mat.Inc] = f - } - } else { - row := make([]float64, ac) - for r := 0; r < ar; r++ { - for i := range row { - row[i] = a.At(r, i) - } - var f float64 - for i, e := range row { - f += e * b.mat.Data[i*b.mat.Inc] - } - v.mat.Data[r*v.mat.Inc] = f - } - } - } -} - -// reuseAs resizes an empty vector to a r×1 vector, -// or checks that a non-empty matrix is r×1. -func (v *Vector) reuseAs(r int) { - if v.isZero() { - v.mat = blas64.Vector{ - Inc: 1, - Data: use(v.mat.Data, r), - } - v.n = r - return - } - if r != v.n { - panic(matrix.ErrShape) - } -} - -func (v *Vector) isZero() bool { - // It must be the case that v.Dims() returns - // zeros in this case. See comment in Reset(). - return v.mat.Inc == 0 -} - -func (v *Vector) isolatedWorkspace(a *Vector) (n *Vector, restore func()) { - l := a.Len() - n = getWorkspaceVec(l, false) - return n, func() { - v.CopyVec(n) - putWorkspaceVec(n) - } -} - -// asDense returns a Dense representation of the receiver with the same -// underlying data. -func (v *Vector) asDense() *Dense { - return &Dense{ - mat: v.asGeneral(), - capRows: v.n, - capCols: 1, - } -} - -// asGeneral returns a blas64.General representation of the receiver with the -// same underlying data. -func (v *Vector) asGeneral() blas64.General { - return blas64.General{ - Rows: v.n, - Cols: 1, - Stride: v.mat.Inc, - Data: v.mat.Data, - } -} diff --git a/vendor/github.com/gonum/plot/plotter/bubbles.go b/vendor/github.com/gonum/plot/plotter/bubbles.go deleted file mode 100644 index 6ee0300c..00000000 --- a/vendor/github.com/gonum/plot/plotter/bubbles.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package plotter - -import ( - "errors" - "image/color" - "math" - - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" -) - -// Bubbles implements the Plotter interface, drawing -// a bubble plot of x, y, z triples where the z value -// determines the radius of the bubble. -type Bubbles struct { - XYZs - - // Color is the color of the bubbles. - color.Color - - // MinRadius and MaxRadius give the minimum - // and maximum bubble radius respectively. - // The radii of each bubble is interpolated linearly - // between these two values. - MinRadius, MaxRadius vg.Length - - // MinZ and MaxZ are the minimum and - // maximum Z values from the data. - MinZ, MaxZ float64 -} - -// NewBubbles creates as new bubble plot plotter for -// the given data, with a minimum and maximum -// bubble radius. -func NewBubbles(xyz XYZer, min, max vg.Length) (*Bubbles, error) { - cpy, err := CopyXYZs(xyz) - if err != nil { - return nil, err - } - if min > max { - return nil, errors.New("Min bubble radius is greater than the max radius") - } - minz := cpy[0].Z - maxz := cpy[0].Z - for _, d := range cpy { - minz = math.Min(minz, d.Z) - maxz = math.Max(maxz, d.Z) - } - return &Bubbles{ - XYZs: cpy, - MinRadius: min, - MaxRadius: max, - MinZ: minz, - MaxZ: maxz, - }, nil -} - -// Plot implements the Plot method of the plot.Plotter interface. -func (bs *Bubbles) Plot(c draw.Canvas, plt *plot.Plot) { - trX, trY := plt.Transforms(&c) - - c.SetColor(bs.Color) - - for _, d := range bs.XYZs { - x := trX(d.X) - y := trY(d.Y) - pt := vg.Point{X: x, Y: y} - if !c.Contains(pt) { - continue - } - - rad := bs.radius(d.Z) - - // draw a circle centered at x, y - var p vg.Path - p.Move(vg.Point{X: x + rad, Y: y}) - p.Arc(pt, rad, 0, 2*math.Pi) - p.Close() - c.Fill(p) - } -} - -// radius returns the radius of a bubble by linear interpolation. -func (bs *Bubbles) radius(z float64) vg.Length { - rng := bs.MaxRadius - bs.MinRadius - if bs.MaxZ == bs.MinZ { - return rng/2 + bs.MinRadius - } - d := (z - bs.MinZ) / (bs.MaxZ - bs.MinZ) - return vg.Length(d)*rng + bs.MinRadius -} - -// DataRange implements the DataRange method -// of the plot.DataRanger interface. -func (bs *Bubbles) DataRange() (xmin, xmax, ymin, ymax float64) { - return XYRange(XYValues{bs.XYZs}) -} - -// GlyphBoxes implements the GlyphBoxes method -// of the plot.GlyphBoxer interface. -func (bs *Bubbles) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox { - boxes := make([]plot.GlyphBox, len(bs.XYZs)) - for i, d := range bs.XYZs { - boxes[i].X = plt.X.Norm(d.X) - boxes[i].Y = plt.Y.Norm(d.Y) - r := bs.radius(d.Z) - boxes[i].Rectangle = vg.Rectangle{ - Min: vg.Point{X: -r, Y: -r}, - Max: vg.Point{X: +r, Y: +r}, - } - } - return boxes -} diff --git a/vendor/gonum.org/v1/gonum/LICENSE b/vendor/gonum.org/v1/gonum/LICENSE new file mode 100644 index 00000000..5f1c3f9c --- /dev/null +++ b/vendor/gonum.org/v1/gonum/LICENSE @@ -0,0 +1,23 @@ +Copyright ©2013 The Gonum Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the gonum project nor the names of its authors and + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/vendor/github.com/gonum/blas/blas.go b/vendor/gonum.org/v1/gonum/blas/blas.go similarity index 74% rename from vendor/github.com/gonum/blas/blas.go rename to vendor/gonum.org/v1/gonum/blas/blas.go index 6c14aac4..43700d02 100644 --- a/vendor/github.com/gonum/blas/blas.go +++ b/vendor/gonum.org/v1/gonum/blas/blas.go @@ -1,110 +1,9 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. +// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -/* -Package blas provides interfaces for the BLAS linear algebra standard. +//go:generate ./conversions.bash -All methods must perform appropriate parameter checking and panic if -provided parameters that do not conform to the requirements specified -by the BLAS standard. - -Quick Reference Guide to the BLAS from http://www.netlib.org/lapack/lug/node145.html - -This version is modified to remove the "order" option. All matrix operations are -on row-order matrices. - -Level 1 BLAS - - dim scalar vector vector scalars 5-element prefixes - struct - - _rotg ( a, b ) S, D - _rotmg( d1, d2, a, b ) S, D - _rot ( n, x, incX, y, incY, c, s ) S, D - _rotm ( n, x, incX, y, incY, param ) S, D - _swap ( n, x, incX, y, incY ) S, D, C, Z - _scal ( n, alpha, x, incX ) S, D, C, Z, Cs, Zd - _copy ( n, x, incX, y, incY ) S, D, C, Z - _axpy ( n, alpha, x, incX, y, incY ) S, D, C, Z - _dot ( n, x, incX, y, incY ) S, D, Ds - _dotu ( n, x, incX, y, incY ) C, Z - _dotc ( n, x, incX, y, incY ) C, Z - __dot ( n, alpha, x, incX, y, incY ) Sds - _nrm2 ( n, x, incX ) S, D, Sc, Dz - _asum ( n, x, incX ) S, D, Sc, Dz - I_amax( n, x, incX ) s, d, c, z - -Level 2 BLAS - - options dim b-width scalar matrix vector scalar vector prefixes - - _gemv ( trans, m, n, alpha, a, lda, x, incX, beta, y, incY ) S, D, C, Z - _gbmv ( trans, m, n, kL, kU, alpha, a, lda, x, incX, beta, y, incY ) S, D, C, Z - _hemv ( uplo, n, alpha, a, lda, x, incX, beta, y, incY ) C, Z - _hbmv ( uplo, n, k, alpha, a, lda, x, incX, beta, y, incY ) C, Z - _hpmv ( uplo, n, alpha, ap, x, incX, beta, y, incY ) C, Z - _symv ( uplo, n, alpha, a, lda, x, incX, beta, y, incY ) S, D - _sbmv ( uplo, n, k, alpha, a, lda, x, incX, beta, y, incY ) S, D - _spmv ( uplo, n, alpha, ap, x, incX, beta, y, incY ) S, D - _trmv ( uplo, trans, diag, n, a, lda, x, incX ) S, D, C, Z - _tbmv ( uplo, trans, diag, n, k, a, lda, x, incX ) S, D, C, Z - _tpmv ( uplo, trans, diag, n, ap, x, incX ) S, D, C, Z - _trsv ( uplo, trans, diag, n, a, lda, x, incX ) S, D, C, Z - _tbsv ( uplo, trans, diag, n, k, a, lda, x, incX ) S, D, C, Z - _tpsv ( uplo, trans, diag, n, ap, x, incX ) S, D, C, Z - - options dim scalar vector vector matrix prefixes - - _ger ( m, n, alpha, x, incX, y, incY, a, lda ) S, D - _geru ( m, n, alpha, x, incX, y, incY, a, lda ) C, Z - _gerc ( m, n, alpha, x, incX, y, incY, a, lda ) C, Z - _her ( uplo, n, alpha, x, incX, a, lda ) C, Z - _hpr ( uplo, n, alpha, x, incX, ap ) C, Z - _her2 ( uplo, n, alpha, x, incX, y, incY, a, lda ) C, Z - _hpr2 ( uplo, n, alpha, x, incX, y, incY, ap ) C, Z - _syr ( uplo, n, alpha, x, incX, a, lda ) S, D - _spr ( uplo, n, alpha, x, incX, ap ) S, D - _syr2 ( uplo, n, alpha, x, incX, y, incY, a, lda ) S, D - _spr2 ( uplo, n, alpha, x, incX, y, incY, ap ) S, D - -Level 3 BLAS - - options dim scalar matrix matrix scalar matrix prefixes - - _gemm ( transA, transB, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc ) S, D, C, Z - _symm ( side, uplo, m, n, alpha, a, lda, b, ldb, beta, c, ldc ) S, D, C, Z - _hemm ( side, uplo, m, n, alpha, a, lda, b, ldb, beta, c, ldc ) C, Z - _syrk ( uplo, trans, n, k, alpha, a, lda, beta, c, ldc ) S, D, C, Z - _herk ( uplo, trans, n, k, alpha, a, lda, beta, c, ldc ) C, Z - _syr2k( uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc ) S, D, C, Z - _her2k( uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc ) C, Z - _trmm ( side, uplo, transA, diag, m, n, alpha, a, lda, b, ldb ) S, D, C, Z - _trsm ( side, uplo, transA, diag, m, n, alpha, a, lda, b, ldb ) S, D, C, Z - -Meaning of prefixes - - S - float32 C - complex64 - D - float64 Z - complex128 - -Matrix types - - GE - GEneral GB - General Band - SY - SYmmetric SB - Symmetric Band SP - Symmetric Packed - HE - HErmitian HB - Hermitian Band HP - Hermitian Packed - TR - TRiangular TB - Triangular Band TP - Triangular Packed - -Options - - trans = NoTrans, Trans, ConjTrans - uplo = Upper, Lower - diag = Nonunit, Unit - side = Left, Right (A or op(A) on the left, or A or op(A) on the right) - -For real matrices, Trans and ConjTrans have the same meaning. -For Hermitian matrices, trans = Trans is not allowed. -For complex symmetric matrices, trans = ConjTrans is not allowed. -*/ package blas // Flag constants indicate Givens transformation H matrix state. diff --git a/vendor/github.com/gonum/blas/blas64/blas64.go b/vendor/gonum.org/v1/gonum/blas/blas64/blas64.go similarity index 98% rename from vendor/github.com/gonum/blas/blas64/blas64.go rename to vendor/gonum.org/v1/gonum/blas/blas64/blas64.go index 088c30e9..11dfaafb 100644 --- a/vendor/github.com/gonum/blas/blas64/blas64.go +++ b/vendor/gonum.org/v1/gonum/blas/blas64/blas64.go @@ -1,16 +1,15 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package blas64 provides a simple interface to the float64 BLAS API. package blas64 import ( - "github.com/gonum/blas" - "github.com/gonum/blas/native" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/gonum" ) -var blas64 blas.Float64 = native.Implementation{} +var blas64 blas.Float64 = gonum.Implementation{} // Use sets the BLAS float64 implementation to be used by subsequent BLAS calls. // The default implementation is native.Implementation. diff --git a/vendor/gonum.org/v1/gonum/blas/blas64/conv.go b/vendor/gonum.org/v1/gonum/blas/blas64/conv.go new file mode 100644 index 00000000..882fd8a7 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/blas/blas64/conv.go @@ -0,0 +1,277 @@ +// Copyright ©2015 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package blas64 + +import "gonum.org/v1/gonum/blas" + +// GeneralCols represents a matrix using the conventional column-major storage scheme. +type GeneralCols General + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions as a and have adequate backing +// data storage. +func (t GeneralCols) From(a General) { + if t.Rows != a.Rows || t.Cols != a.Cols { + panic("blas64: mismatched dimension") + } + if len(t.Data) < (t.Cols-1)*t.Stride+t.Rows { + panic("blas64: short data slice") + } + for i := 0; i < a.Rows; i++ { + for j, v := range a.Data[i*a.Stride : i*a.Stride+a.Cols] { + t.Data[i+j*t.Stride] = v + } + } +} + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions as a and have adequate backing +// data storage. +func (t General) From(a GeneralCols) { + if t.Rows != a.Rows || t.Cols != a.Cols { + panic("blas64: mismatched dimension") + } + if len(t.Data) < (t.Rows-1)*t.Stride+t.Cols { + panic("blas64: short data slice") + } + for j := 0; j < a.Cols; j++ { + for i, v := range a.Data[j*a.Stride : j*a.Stride+a.Rows] { + t.Data[i*t.Stride+j] = v + } + } +} + +// TriangularCols represents a matrix using the conventional column-major storage scheme. +type TriangularCols Triangular + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions, uplo and diag as a and have +// adequate backing data storage. +func (t TriangularCols) From(a Triangular) { + if t.N != a.N { + panic("blas64: mismatched dimension") + } + if t.Uplo != a.Uplo { + panic("blas64: mismatched BLAS uplo") + } + if t.Diag != a.Diag { + panic("blas64: mismatched BLAS diag") + } + switch a.Uplo { + default: + panic("blas64: bad BLAS uplo") + case blas.Upper: + for i := 0; i < a.N; i++ { + for j := i; j < a.N; j++ { + t.Data[i+j*t.Stride] = a.Data[i*a.Stride+j] + } + } + case blas.Lower: + for i := 0; i < a.N; i++ { + for j := 0; j <= i; j++ { + t.Data[i+j*t.Stride] = a.Data[i*a.Stride+j] + } + } + case blas.All: + for i := 0; i < a.N; i++ { + for j := 0; j < a.N; j++ { + t.Data[i+j*t.Stride] = a.Data[i*a.Stride+j] + } + } + } +} + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions, uplo and diag as a and have +// adequate backing data storage. +func (t Triangular) From(a TriangularCols) { + if t.N != a.N { + panic("blas64: mismatched dimension") + } + if t.Uplo != a.Uplo { + panic("blas64: mismatched BLAS uplo") + } + if t.Diag != a.Diag { + panic("blas64: mismatched BLAS diag") + } + switch a.Uplo { + default: + panic("blas64: bad BLAS uplo") + case blas.Upper: + for i := 0; i < a.N; i++ { + for j := i; j < a.N; j++ { + t.Data[i*t.Stride+j] = a.Data[i+j*a.Stride] + } + } + case blas.Lower: + for i := 0; i < a.N; i++ { + for j := 0; j <= i; j++ { + t.Data[i*t.Stride+j] = a.Data[i+j*a.Stride] + } + } + case blas.All: + for i := 0; i < a.N; i++ { + for j := 0; j < a.N; j++ { + t.Data[i*t.Stride+j] = a.Data[i+j*a.Stride] + } + } + } +} + +// BandCols represents a matrix using the band column-major storage scheme. +type BandCols Band + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions and bandwidth as a and have +// adequate backing data storage. +func (t BandCols) From(a Band) { + if t.Rows != a.Rows || t.Cols != a.Cols { + panic("blas64: mismatched dimension") + } + if t.KL != a.KL || t.KU != a.KU { + panic("blas64: mismatched bandwidth") + } + if a.Stride < a.KL+a.KU+1 { + panic("blas64: short stride for source") + } + if t.Stride < t.KL+t.KU+1 { + panic("blas64: short stride for destination") + } + for i := 0; i < a.Rows; i++ { + for j := max(0, i-a.KL); j < min(i+a.KU+1, a.Cols); j++ { + t.Data[i+t.KU-j+j*t.Stride] = a.Data[j+a.KL-i+i*a.Stride] + } + } +} + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions and bandwidth as a and have +// adequate backing data storage. +func (t Band) From(a BandCols) { + if t.Rows != a.Rows || t.Cols != a.Cols { + panic("blas64: mismatched dimension") + } + if t.KL != a.KL || t.KU != a.KU { + panic("blas64: mismatched bandwidth") + } + if a.Stride < a.KL+a.KU+1 { + panic("blas64: short stride for source") + } + if t.Stride < t.KL+t.KU+1 { + panic("blas64: short stride for destination") + } + for j := 0; j < a.Cols; j++ { + for i := max(0, j-a.KU); i < min(j+a.KL+1, a.Rows); i++ { + t.Data[j+a.KL-i+i*a.Stride] = a.Data[i+t.KU-j+j*t.Stride] + } + } +} + +// TriangularBandCols represents a symmetric matrix using the band column-major storage scheme. +type TriangularBandCols TriangularBand + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions, bandwidth and uplo as a and +// have adequate backing data storage. +func (t TriangularBandCols) From(a TriangularBand) { + if t.N != a.N { + panic("blas64: mismatched dimension") + } + if t.K != a.K { + panic("blas64: mismatched bandwidth") + } + if a.Stride < a.K+1 { + panic("blas64: short stride for source") + } + if t.Stride < t.K+1 { + panic("blas64: short stride for destination") + } + if t.Uplo != a.Uplo { + panic("blas64: mismatched BLAS uplo") + } + if t.Diag != a.Diag { + panic("blas64: mismatched BLAS diag") + } + dst := BandCols{ + Rows: t.N, Cols: t.N, + Stride: t.Stride, + Data: t.Data, + } + src := Band{ + Rows: a.N, Cols: a.N, + Stride: a.Stride, + Data: a.Data, + } + switch a.Uplo { + default: + panic("blas64: bad BLAS uplo") + case blas.Upper: + dst.KU = t.K + src.KU = a.K + case blas.Lower: + dst.KL = t.K + src.KL = a.K + } + dst.From(src) +} + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions, bandwidth and uplo as a and +// have adequate backing data storage. +func (t TriangularBand) From(a TriangularBandCols) { + if t.N != a.N { + panic("blas64: mismatched dimension") + } + if t.K != a.K { + panic("blas64: mismatched bandwidth") + } + if a.Stride < a.K+1 { + panic("blas64: short stride for source") + } + if t.Stride < t.K+1 { + panic("blas64: short stride for destination") + } + if t.Uplo != a.Uplo { + panic("blas64: mismatched BLAS uplo") + } + if t.Diag != a.Diag { + panic("blas64: mismatched BLAS diag") + } + dst := Band{ + Rows: t.N, Cols: t.N, + Stride: t.Stride, + Data: t.Data, + } + src := BandCols{ + Rows: a.N, Cols: a.N, + Stride: a.Stride, + Data: a.Data, + } + switch a.Uplo { + default: + panic("blas64: bad BLAS uplo") + case blas.Upper: + dst.KU = t.K + src.KU = a.K + case blas.Lower: + dst.KL = t.K + src.KL = a.K + } + dst.From(src) +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/vendor/gonum.org/v1/gonum/blas/blas64/conv_symmetric.go b/vendor/gonum.org/v1/gonum/blas/blas64/conv_symmetric.go new file mode 100644 index 00000000..5146f1a1 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/blas/blas64/conv_symmetric.go @@ -0,0 +1,153 @@ +// Copyright ©2015 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package blas64 + +import "gonum.org/v1/gonum/blas" + +// SymmetricCols represents a matrix using the conventional column-major storage scheme. +type SymmetricCols Symmetric + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions and uplo as a and have adequate +// backing data storage. +func (t SymmetricCols) From(a Symmetric) { + if t.N != a.N { + panic("blas64: mismatched dimension") + } + if t.Uplo != a.Uplo { + panic("blas64: mismatched BLAS uplo") + } + switch a.Uplo { + default: + panic("blas64: bad BLAS uplo") + case blas.Upper: + for i := 0; i < a.N; i++ { + for j := i; j < a.N; j++ { + t.Data[i+j*t.Stride] = a.Data[i*a.Stride+j] + } + } + case blas.Lower: + for i := 0; i < a.N; i++ { + for j := 0; j <= i; j++ { + t.Data[i+j*t.Stride] = a.Data[i*a.Stride+j] + } + } + } +} + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions and uplo as a and have adequate +// backing data storage. +func (t Symmetric) From(a SymmetricCols) { + if t.N != a.N { + panic("blas64: mismatched dimension") + } + if t.Uplo != a.Uplo { + panic("blas64: mismatched BLAS uplo") + } + switch a.Uplo { + default: + panic("blas64: bad BLAS uplo") + case blas.Upper: + for i := 0; i < a.N; i++ { + for j := i; j < a.N; j++ { + t.Data[i*t.Stride+j] = a.Data[i+j*a.Stride] + } + } + case blas.Lower: + for i := 0; i < a.N; i++ { + for j := 0; j <= i; j++ { + t.Data[i*t.Stride+j] = a.Data[i+j*a.Stride] + } + } + } +} + +// SymmetricBandCols represents a symmetric matrix using the band column-major storage scheme. +type SymmetricBandCols SymmetricBand + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions, bandwidth and uplo as a and +// have adequate backing data storage. +func (t SymmetricBandCols) From(a SymmetricBand) { + if t.N != a.N { + panic("blas64: mismatched dimension") + } + if t.K != a.K { + panic("blas64: mismatched bandwidth") + } + if a.Stride < a.K+1 { + panic("blas64: short stride for source") + } + if t.Stride < t.K+1 { + panic("blas64: short stride for destination") + } + if t.Uplo != a.Uplo { + panic("blas64: mismatched BLAS uplo") + } + dst := BandCols{ + Rows: t.N, Cols: t.N, + Stride: t.Stride, + Data: t.Data, + } + src := Band{ + Rows: a.N, Cols: a.N, + Stride: a.Stride, + Data: a.Data, + } + switch a.Uplo { + default: + panic("blas64: bad BLAS uplo") + case blas.Upper: + dst.KU = t.K + src.KU = a.K + case blas.Lower: + dst.KL = t.K + src.KL = a.K + } + dst.From(src) +} + +// From fills the receiver with elements from a. The receiver +// must have the same dimensions, bandwidth and uplo as a and +// have adequate backing data storage. +func (t SymmetricBand) From(a SymmetricBandCols) { + if t.N != a.N { + panic("blas64: mismatched dimension") + } + if t.K != a.K { + panic("blas64: mismatched bandwidth") + } + if a.Stride < a.K+1 { + panic("blas64: short stride for source") + } + if t.Stride < t.K+1 { + panic("blas64: short stride for destination") + } + if t.Uplo != a.Uplo { + panic("blas64: mismatched BLAS uplo") + } + dst := Band{ + Rows: t.N, Cols: t.N, + Stride: t.Stride, + Data: t.Data, + } + src := BandCols{ + Rows: a.N, Cols: a.N, + Stride: a.Stride, + Data: a.Data, + } + switch a.Uplo { + default: + panic("blas64: bad BLAS uplo") + case blas.Upper: + dst.KU = t.K + src.KU = a.K + case blas.Lower: + dst.KL = t.K + src.KL = a.K + } + dst.From(src) +} diff --git a/vendor/gonum.org/v1/gonum/blas/blas64/doc.go b/vendor/gonum.org/v1/gonum/blas/blas64/doc.go new file mode 100644 index 00000000..7410cee4 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/blas/blas64/doc.go @@ -0,0 +1,6 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package blas64 provides a simple interface to the float64 BLAS API. +package blas64 // import "gonum.org/v1/gonum/blas/blas64" diff --git a/vendor/gonum.org/v1/gonum/blas/doc.go b/vendor/gonum.org/v1/gonum/blas/doc.go new file mode 100644 index 00000000..ea4b16c9 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/blas/doc.go @@ -0,0 +1,108 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/* +Package blas provides interfaces for the BLAS linear algebra standard. + +All methods must perform appropriate parameter checking and panic if +provided parameters that do not conform to the requirements specified +by the BLAS standard. + +Quick Reference Guide to the BLAS from http://www.netlib.org/lapack/lug/node145.html + +This version is modified to remove the "order" option. All matrix operations are +on row-order matrices. + +Level 1 BLAS + + dim scalar vector vector scalars 5-element prefixes + struct + + _rotg ( a, b ) S, D + _rotmg( d1, d2, a, b ) S, D + _rot ( n, x, incX, y, incY, c, s ) S, D + _rotm ( n, x, incX, y, incY, param ) S, D + _swap ( n, x, incX, y, incY ) S, D, C, Z + _scal ( n, alpha, x, incX ) S, D, C, Z, Cs, Zd + _copy ( n, x, incX, y, incY ) S, D, C, Z + _axpy ( n, alpha, x, incX, y, incY ) S, D, C, Z + _dot ( n, x, incX, y, incY ) S, D, Ds + _dotu ( n, x, incX, y, incY ) C, Z + _dotc ( n, x, incX, y, incY ) C, Z + __dot ( n, alpha, x, incX, y, incY ) Sds + _nrm2 ( n, x, incX ) S, D, Sc, Dz + _asum ( n, x, incX ) S, D, Sc, Dz + I_amax( n, x, incX ) s, d, c, z + +Level 2 BLAS + + options dim b-width scalar matrix vector scalar vector prefixes + + _gemv ( trans, m, n, alpha, a, lda, x, incX, beta, y, incY ) S, D, C, Z + _gbmv ( trans, m, n, kL, kU, alpha, a, lda, x, incX, beta, y, incY ) S, D, C, Z + _hemv ( uplo, n, alpha, a, lda, x, incX, beta, y, incY ) C, Z + _hbmv ( uplo, n, k, alpha, a, lda, x, incX, beta, y, incY ) C, Z + _hpmv ( uplo, n, alpha, ap, x, incX, beta, y, incY ) C, Z + _symv ( uplo, n, alpha, a, lda, x, incX, beta, y, incY ) S, D + _sbmv ( uplo, n, k, alpha, a, lda, x, incX, beta, y, incY ) S, D + _spmv ( uplo, n, alpha, ap, x, incX, beta, y, incY ) S, D + _trmv ( uplo, trans, diag, n, a, lda, x, incX ) S, D, C, Z + _tbmv ( uplo, trans, diag, n, k, a, lda, x, incX ) S, D, C, Z + _tpmv ( uplo, trans, diag, n, ap, x, incX ) S, D, C, Z + _trsv ( uplo, trans, diag, n, a, lda, x, incX ) S, D, C, Z + _tbsv ( uplo, trans, diag, n, k, a, lda, x, incX ) S, D, C, Z + _tpsv ( uplo, trans, diag, n, ap, x, incX ) S, D, C, Z + + options dim scalar vector vector matrix prefixes + + _ger ( m, n, alpha, x, incX, y, incY, a, lda ) S, D + _geru ( m, n, alpha, x, incX, y, incY, a, lda ) C, Z + _gerc ( m, n, alpha, x, incX, y, incY, a, lda ) C, Z + _her ( uplo, n, alpha, x, incX, a, lda ) C, Z + _hpr ( uplo, n, alpha, x, incX, ap ) C, Z + _her2 ( uplo, n, alpha, x, incX, y, incY, a, lda ) C, Z + _hpr2 ( uplo, n, alpha, x, incX, y, incY, ap ) C, Z + _syr ( uplo, n, alpha, x, incX, a, lda ) S, D + _spr ( uplo, n, alpha, x, incX, ap ) S, D + _syr2 ( uplo, n, alpha, x, incX, y, incY, a, lda ) S, D + _spr2 ( uplo, n, alpha, x, incX, y, incY, ap ) S, D + +Level 3 BLAS + + options dim scalar matrix matrix scalar matrix prefixes + + _gemm ( transA, transB, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc ) S, D, C, Z + _symm ( side, uplo, m, n, alpha, a, lda, b, ldb, beta, c, ldc ) S, D, C, Z + _hemm ( side, uplo, m, n, alpha, a, lda, b, ldb, beta, c, ldc ) C, Z + _syrk ( uplo, trans, n, k, alpha, a, lda, beta, c, ldc ) S, D, C, Z + _herk ( uplo, trans, n, k, alpha, a, lda, beta, c, ldc ) C, Z + _syr2k( uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc ) S, D, C, Z + _her2k( uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc ) C, Z + _trmm ( side, uplo, transA, diag, m, n, alpha, a, lda, b, ldb ) S, D, C, Z + _trsm ( side, uplo, transA, diag, m, n, alpha, a, lda, b, ldb ) S, D, C, Z + +Meaning of prefixes + + S - float32 C - complex64 + D - float64 Z - complex128 + +Matrix types + + GE - GEneral GB - General Band + SY - SYmmetric SB - Symmetric Band SP - Symmetric Packed + HE - HErmitian HB - Hermitian Band HP - Hermitian Packed + TR - TRiangular TB - Triangular Band TP - Triangular Packed + +Options + + trans = NoTrans, Trans, ConjTrans + uplo = Upper, Lower + diag = Nonunit, Unit + side = Left, Right (A or op(A) on the left, or A or op(A) on the right) + +For real matrices, Trans and ConjTrans have the same meaning. +For Hermitian matrices, trans = Trans is not allowed. +For complex symmetric matrices, trans = ConjTrans is not allowed. +*/ +package blas // import "gonum.org/v1/gonum/blas" diff --git a/vendor/gonum.org/v1/gonum/blas/gonum/cmplx.go b/vendor/gonum.org/v1/gonum/blas/gonum/cmplx.go new file mode 100644 index 00000000..fe7db2ce --- /dev/null +++ b/vendor/gonum.org/v1/gonum/blas/gonum/cmplx.go @@ -0,0 +1,185 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gonum + +import "gonum.org/v1/gonum/blas" + +var ( + _ blas.Complex64 = Implementation{} + _ blas.Complex128 = Implementation{} +) + +// TODO(btracey): Replace this as complex routines are added, and instead +// automatically generate the complex64 routines from the complex128 ones. + +var noComplex = "native: implementation does not implement this routine, see the cgo wrapper in gonum.org/v1/netlib/blas" + +// Level 1 complex64 routines. + +func (Implementation) Cdotu(n int, x []complex64, incX int, y []complex64, incY int) (dotu complex64) { + panic(noComplex) +} +func (Implementation) Cdotc(n int, x []complex64, incX int, y []complex64, incY int) (dotc complex64) { + panic(noComplex) +} +func (Implementation) Scnrm2(n int, x []complex64, incX int) float32 { + panic(noComplex) +} +func (Implementation) Scasum(n int, x []complex64, incX int) float32 { + panic(noComplex) +} +func (Implementation) Icamax(n int, x []complex64, incX int) int { + panic(noComplex) +} +func (Implementation) Cswap(n int, x []complex64, incX int, y []complex64, incY int) { + panic(noComplex) +} +func (Implementation) Ccopy(n int, x []complex64, incX int, y []complex64, incY int) { + panic(noComplex) +} +func (Implementation) Caxpy(n int, alpha complex64, x []complex64, incX int, y []complex64, incY int) { + panic(noComplex) +} +func (Implementation) Cscal(n int, alpha complex64, x []complex64, incX int) { + panic(noComplex) +} +func (Implementation) Csscal(n int, alpha float32, x []complex64, incX int) { + panic(noComplex) +} + +// Level 2 complex64 routines. + +func (Implementation) Cgemv(tA blas.Transpose, m, n int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int) { + panic(noComplex) +} +func (Implementation) Cgbmv(tA blas.Transpose, m, n, kL, kU int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int) { + panic(noComplex) +} +func (Implementation) Ctrmv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int, a []complex64, lda int, x []complex64, incX int) { + panic(noComplex) +} +func (Implementation) Ctbmv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n, k int, a []complex64, lda int, x []complex64, incX int) { + panic(noComplex) +} +func (Implementation) Ctpmv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int, ap []complex64, x []complex64, incX int) { + panic(noComplex) +} +func (Implementation) Ctrsv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int, a []complex64, lda int, x []complex64, incX int) { + panic(noComplex) +} +func (Implementation) Ctbsv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n, k int, a []complex64, lda int, x []complex64, incX int) { + panic(noComplex) +} +func (Implementation) Ctpsv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int, ap []complex64, x []complex64, incX int) { + panic(noComplex) +} +func (Implementation) Chemv(ul blas.Uplo, n int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int) { + panic(noComplex) +} +func (Implementation) Chbmv(ul blas.Uplo, n, k int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int) { + panic(noComplex) +} +func (Implementation) Chpmv(ul blas.Uplo, n int, alpha complex64, ap []complex64, x []complex64, incX int, beta complex64, y []complex64, incY int) { + panic(noComplex) +} +func (Implementation) Cgeru(m, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, a []complex64, lda int) { + panic(noComplex) +} +func (Implementation) Cgerc(m, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, a []complex64, lda int) { + panic(noComplex) +} +func (Implementation) Cher(ul blas.Uplo, n int, alpha float32, x []complex64, incX int, a []complex64, lda int) { + panic(noComplex) +} +func (Implementation) Chpr(ul blas.Uplo, n int, alpha float32, x []complex64, incX int, a []complex64) { + panic(noComplex) +} +func (Implementation) Cher2(ul blas.Uplo, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, a []complex64, lda int) { + panic(noComplex) +} +func (Implementation) Chpr2(ul blas.Uplo, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, ap []complex64) { + panic(noComplex) +} + +// Level 3 complex64 routines. + +func (Implementation) Cgemm(tA, tB blas.Transpose, m, n, k int, alpha complex64, a []complex64, lda int, b []complex64, ldb int, beta complex64, c []complex64, ldc int) { + panic(noComplex) +} +func (Implementation) Csymm(s blas.Side, ul blas.Uplo, m, n int, alpha complex64, a []complex64, lda int, b []complex64, ldb int, beta complex64, c []complex64, ldc int) { + panic(noComplex) +} +func (Implementation) Csyrk(ul blas.Uplo, t blas.Transpose, n, k int, alpha complex64, a []complex64, lda int, beta complex64, c []complex64, ldc int) { + panic(noComplex) +} +func (Implementation) Csyr2k(ul blas.Uplo, t blas.Transpose, n, k int, alpha complex64, a []complex64, lda int, b []complex64, ldb int, beta complex64, c []complex64, ldc int) { + panic(noComplex) +} +func (Implementation) Ctrmm(s blas.Side, ul blas.Uplo, tA blas.Transpose, d blas.Diag, m, n int, alpha complex64, a []complex64, lda int, b []complex64, ldb int) { + panic(noComplex) +} +func (Implementation) Ctrsm(s blas.Side, ul blas.Uplo, tA blas.Transpose, d blas.Diag, m, n int, alpha complex64, a []complex64, lda int, b []complex64, ldb int) { + panic(noComplex) +} +func (Implementation) Chemm(s blas.Side, ul blas.Uplo, m, n int, alpha complex64, a []complex64, lda int, b []complex64, ldb int, beta complex64, c []complex64, ldc int) { + panic(noComplex) +} +func (Implementation) Cherk(ul blas.Uplo, t blas.Transpose, n, k int, alpha float32, a []complex64, lda int, beta float32, c []complex64, ldc int) { + panic(noComplex) +} +func (Implementation) Cher2k(ul blas.Uplo, t blas.Transpose, n, k int, alpha complex64, a []complex64, lda int, b []complex64, ldb int, beta float32, c []complex64, ldc int) { + panic(noComplex) +} + +// Level 2 complex128 routines. + +func (Implementation) Zgbmv(tA blas.Transpose, m, n int, kL int, kU int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int) { + panic(noComplex) +} +func (Implementation) Ztbmv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n, k int, a []complex128, lda int, x []complex128, incX int) { + panic(noComplex) +} +func (Implementation) Ztpmv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int, ap []complex128, x []complex128, incX int) { + panic(noComplex) +} +func (Implementation) Ztbsv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n, k int, a []complex128, lda int, x []complex128, incX int) { + panic(noComplex) +} +func (Implementation) Ztpsv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int, ap []complex128, x []complex128, incX int) { + panic(noComplex) +} +func (Implementation) Zhbmv(ul blas.Uplo, n, k int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int) { + panic(noComplex) +} + +// Level 3 complex128 routines. + +func (Implementation) Zgemm(tA, tB blas.Transpose, m, n, k int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int) { + panic(noComplex) +} +func (Implementation) Zsymm(s blas.Side, ul blas.Uplo, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int) { + panic(noComplex) +} +func (Implementation) Zsyrk(ul blas.Uplo, t blas.Transpose, n, k int, alpha complex128, a []complex128, lda int, beta complex128, c []complex128, ldc int) { + panic(noComplex) +} +func (Implementation) Zsyr2k(ul blas.Uplo, t blas.Transpose, n, k int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int) { + panic(noComplex) +} +func (Implementation) Ztrmm(s blas.Side, ul blas.Uplo, tA blas.Transpose, d blas.Diag, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int) { + panic(noComplex) +} +func (Implementation) Ztrsm(s blas.Side, ul blas.Uplo, tA blas.Transpose, d blas.Diag, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int) { + panic(noComplex) +} +func (Implementation) Zhemm(s blas.Side, ul blas.Uplo, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int) { + panic(noComplex) +} +func (Implementation) Zherk(ul blas.Uplo, t blas.Transpose, n, k int, alpha float64, a []complex128, lda int, beta float64, c []complex128, ldc int) { + panic(noComplex) +} +func (Implementation) Zher2k(ul blas.Uplo, t blas.Transpose, n, k int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta float64, c []complex128, ldc int) { + panic(noComplex) +} diff --git a/vendor/github.com/gonum/blas/native/dgemm.go b/vendor/gonum.org/v1/gonum/blas/gonum/dgemm.go similarity index 92% rename from vendor/github.com/gonum/blas/native/dgemm.go rename to vendor/gonum.org/v1/gonum/blas/gonum/dgemm.go index 69dfbfb4..e33a4d55 100644 --- a/vendor/github.com/gonum/blas/native/dgemm.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/dgemm.go @@ -1,15 +1,15 @@ -// Copyright ©2014 The gonum Authors. All rights reserved. +// Copyright ©2014 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "runtime" "sync" - "github.com/gonum/blas" - "github.com/gonum/internal/asm/f64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/internal/asm/f64" ) // Dgemm computes @@ -25,17 +25,17 @@ func (Implementation) Dgemm(tA, tB blas.Transpose, m, n, k int, alpha float64, a } aTrans := tA == blas.Trans || tA == blas.ConjTrans if aTrans { - checkMatrix64(k, m, a, lda) + checkDMatrix('a', k, m, a, lda) } else { - checkMatrix64(m, k, a, lda) + checkDMatrix('a', m, k, a, lda) } bTrans := tB == blas.Trans || tB == blas.ConjTrans if bTrans { - checkMatrix64(n, k, b, ldb) + checkDMatrix('b', n, k, b, ldb) } else { - checkMatrix64(k, n, b, ldb) + checkDMatrix('b', k, n, b, ldb) } - checkMatrix64(m, n, c, ldc) + checkDMatrix('c', m, n, c, ldc) // scale c if beta != 1 { @@ -121,7 +121,7 @@ func dgemmParallel(aTrans, bTrans bool, m, n, k int, a []float64, lda int, b []f go func() { defer wg.Done() // Make local copies of otherwise global variables to reduce shared memory. - // This has a noticable effect on benchmarks in some cases. + // This has a noticeable effect on benchmarks in some cases. alpha := alpha aTrans := aTrans bTrans := bTrans @@ -259,18 +259,3 @@ func dgemmSerialTransTrans(m, n, k int, a []float64, lda int, b []float64, ldb i func sliceView64(a []float64, lda, i, j, r, c int) []float64 { return a[i*lda+j : (i+r-1)*lda+j+c] } - -func checkMatrix64(m, n int, a []float64, lda int) { - if m < 0 { - panic("blas: rows < 0") - } - if n < 0 { - panic("blas: cols < 0") - } - if lda < n { - panic("blas: illegal stride") - } - if len(a) < (m-1)*lda+n { - panic("blas: insufficient matrix slice length") - } -} diff --git a/vendor/github.com/gonum/blas/native/doc.go b/vendor/gonum.org/v1/gonum/blas/gonum/doc.go similarity index 92% rename from vendor/github.com/gonum/blas/native/doc.go rename to vendor/gonum.org/v1/gonum/blas/gonum/doc.go index cb63fe77..dbe376c4 100644 --- a/vendor/github.com/gonum/blas/native/doc.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/doc.go @@ -7,12 +7,12 @@ /* Package native is a Go implementation of the BLAS API. This implementation panics when the input arguments are invalid as per the standard, for example -if a vector increment is zero. Please note that the treatment of NaN values +if a vector increment is zero. Note that the treatment of NaN values is not specified, and differs among the BLAS implementations. -github.com/gonum/blas/blas64 provides helpful wrapper functions to the BLAS +gonum.org/v1/gonum/blas/blas64 provides helpful wrapper functions to the BLAS interface. The rest of this text describes the layout of the data for the input types. -Please note that in the function documentation, x[i] refers to the i^th element +Note that in the function documentation, x[i] refers to the i^th element of the vector, which will be different from the i^th element of the slice if incX != 1. @@ -85,4 +85,4 @@ which is given to the BLAS routine as [∗ 1 2 3 4 ...]. See http://www.crest.iu.edu/research/mtl/reference/html/banded.html for more information */ -package native +package gonum // import "gonum.org/v1/gonum/blas/gonum" diff --git a/vendor/gonum.org/v1/gonum/blas/gonum/general_double.go b/vendor/gonum.org/v1/gonum/blas/gonum/general_double.go new file mode 100644 index 00000000..f7012ffc --- /dev/null +++ b/vendor/gonum.org/v1/gonum/blas/gonum/general_double.go @@ -0,0 +1,50 @@ +// Copyright ©2014 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gonum + +import ( + "math" +) + +type general64 struct { + data []float64 + rows, cols int + stride int +} + +func (g general64) clone() general64 { + data := make([]float64, len(g.data)) + copy(data, g.data) + return general64{ + data: data, + rows: g.rows, + cols: g.cols, + stride: g.stride, + } +} + +func (g general64) equal(a general64) bool { + if g.rows != a.rows || g.cols != a.cols || g.stride != a.stride { + return false + } + for i, v := range g.data { + if a.data[i] != v { + return false + } + } + return true +} + +func (g general64) equalWithinAbs(a general64, tol float64) bool { + if g.rows != a.rows || g.cols != a.cols || g.stride != a.stride { + return false + } + for i, v := range g.data { + if math.Abs(a.data[i]-v) > tol { + return false + } + } + return true +} diff --git a/vendor/gonum.org/v1/gonum/blas/gonum/general_single.go b/vendor/gonum.org/v1/gonum/blas/gonum/general_single.go new file mode 100644 index 00000000..f5fcadc9 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/blas/gonum/general_single.go @@ -0,0 +1,52 @@ +// Code generated by "go generate gonum.org/v1/gonum/blas/gonum”; DO NOT EDIT. + +// Copyright ©2014 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gonum + +import ( + math "gonum.org/v1/gonum/internal/math32" +) + +type general32 struct { + data []float32 + rows, cols int + stride int +} + +func (g general32) clone() general32 { + data := make([]float32, len(g.data)) + copy(data, g.data) + return general32{ + data: data, + rows: g.rows, + cols: g.cols, + stride: g.stride, + } +} + +func (g general32) equal(a general32) bool { + if g.rows != a.rows || g.cols != a.cols || g.stride != a.stride { + return false + } + for i, v := range g.data { + if a.data[i] != v { + return false + } + } + return true +} + +func (g general32) equalWithinAbs(a general32, tol float32) bool { + if g.rows != a.rows || g.cols != a.cols || g.stride != a.stride { + return false + } + for i, v := range g.data { + if math.Abs(a.data[i]-v) > tol { + return false + } + } + return true +} diff --git a/vendor/github.com/gonum/blas/native/native.go b/vendor/gonum.org/v1/gonum/blas/gonum/gonum.go similarity index 51% rename from vendor/github.com/gonum/blas/native/native.go rename to vendor/gonum.org/v1/gonum/blas/gonum/gonum.go index 00126769..44e391d7 100644 --- a/vendor/github.com/gonum/blas/native/native.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/gonum.go @@ -1,10 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:generate ./single_precision.bash -package native +package gonum + +import "math" type Implementation struct{} @@ -43,9 +45,6 @@ const ( buffMul = 4 // how big is the buffer relative to the number of workers ) -// [SD]gemm debugging constant. -const debug = false - // subMul is a common type shared by [SD]gemm. type subMul struct { i, j int // index of block @@ -65,8 +64,70 @@ func min(a, b int) int { return a } -// blocks returns the number of divisons of the dimension length with the given +func checkSMatrix(name byte, m, n int, a []float32, lda int) { + if m < 0 { + panic(mLT0) + } + if n < 0 { + panic(nLT0) + } + if lda < n { + panic("blas: illegal stride of " + string(name)) + } + if len(a) < (m-1)*lda+n { + panic("blas: index of " + string(name) + " out of range") + } +} + +func checkDMatrix(name byte, m, n int, a []float64, lda int) { + if m < 0 { + panic(mLT0) + } + if n < 0 { + panic(nLT0) + } + if lda < n { + panic("blas: illegal stride of " + string(name)) + } + if len(a) < (m-1)*lda+n { + panic("blas: index of " + string(name) + " out of range") + } +} + +func checkZMatrix(name byte, m, n int, a []complex128, lda int) { + if m < 0 { + panic(mLT0) + } + if n < 0 { + panic(nLT0) + } + if lda < max(1, n) { + panic("blas: illegal stride of " + string(name)) + } + if len(a) < (m-1)*lda+n { + panic("blas: insufficient " + string(name) + " matrix slice length") + } +} + +func checkZVector(name byte, n int, x []complex128, incX int) { + if n < 0 { + panic(nLT0) + } + if incX == 0 { + panic(zeroIncX) + } + if (incX > 0 && (n-1)*incX >= len(x)) || (incX < 0 && (1-n)*incX >= len(x)) { + panic("blas: insufficient " + string(name) + " vector slice length") + } +} + +// blocks returns the number of divisions of the dimension length with the given // block size. func blocks(dim, bsize int) int { return (dim + bsize - 1) / bsize } + +// dcabs1 returns |real(z)|+|imag(z)|. +func dcabs1(z complex128) float64 { + return math.Abs(real(z)) + math.Abs(imag(z)) +} diff --git a/vendor/gonum.org/v1/gonum/blas/gonum/level1cmplx128.go b/vendor/gonum.org/v1/gonum/blas/gonum/level1cmplx128.go new file mode 100644 index 00000000..34fa1ac8 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level1cmplx128.go @@ -0,0 +1,442 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gonum + +import ( + "math" + + "gonum.org/v1/gonum/internal/asm/c128" +) + +// Dzasum returns the sum of the absolute values of the elements of x +// \sum_i |Re(x[i])| + |Im(x[i])| +// Dzasum returns 0 if incX is negative. +func (Implementation) Dzasum(n int, x []complex128, incX int) float64 { + if n < 0 { + panic(negativeN) + } + if incX < 1 { + if incX == 0 { + panic(zeroIncX) + } + return 0 + } + var sum float64 + if incX == 1 { + if len(x) < n { + panic(badX) + } + for _, v := range x[:n] { + sum += dcabs1(v) + } + return sum + } + if (n-1)*incX >= len(x) { + panic(badX) + } + for i := 0; i < n; i++ { + v := x[i*incX] + sum += dcabs1(v) + } + return sum +} + +// Dznrm2 computes the Euclidean norm of the complex vector x, +// ‖x‖_2 = sqrt(\sum_i x[i] * conj(x[i])). +// This function returns 0 if incX is negative. +func (Implementation) Dznrm2(n int, x []complex128, incX int) float64 { + if incX < 1 { + if incX == 0 { + panic(zeroIncX) + } + return 0 + } + if n < 1 { + if n == 0 { + return 0 + } + panic(negativeN) + } + if (n-1)*incX >= len(x) { + panic(badX) + } + var ( + scale float64 + ssq float64 = 1 + ) + if incX == 1 { + for _, v := range x[:n] { + re, im := math.Abs(real(v)), math.Abs(imag(v)) + if re != 0 { + if re > scale { + ssq = 1 + ssq*(scale/re)*(scale/re) + scale = re + } else { + ssq += (re / scale) * (re / scale) + } + } + if im != 0 { + if im > scale { + ssq = 1 + ssq*(scale/im)*(scale/im) + scale = im + } else { + ssq += (im / scale) * (im / scale) + } + } + } + if math.IsInf(scale, 1) { + return math.Inf(1) + } + return scale * math.Sqrt(ssq) + } + for ix := 0; ix < n*incX; ix += incX { + re, im := math.Abs(real(x[ix])), math.Abs(imag(x[ix])) + if re != 0 { + if re > scale { + ssq = 1 + ssq*(scale/re)*(scale/re) + scale = re + } else { + ssq += (re / scale) * (re / scale) + } + } + if im != 0 { + if im > scale { + ssq = 1 + ssq*(scale/im)*(scale/im) + scale = im + } else { + ssq += (im / scale) * (im / scale) + } + } + } + if math.IsInf(scale, 1) { + return math.Inf(1) + } + return scale * math.Sqrt(ssq) +} + +// Izamax returns the index of the first element of x having largest |Re(·)|+|Im(·)|. +// Izamax returns -1 if n is 0 or incX is negative. +func (Implementation) Izamax(n int, x []complex128, incX int) int { + if incX < 1 { + if incX == 0 { + panic(zeroIncX) + } + // Return invalid index. + return -1 + } + if n < 1 { + if n == 0 { + // Return invalid index. + return -1 + } + panic(negativeN) + } + if len(x) <= (n-1)*incX { + panic(badX) + } + idx := 0 + max := dcabs1(x[0]) + if incX == 1 { + for i, v := range x[1:n] { + absV := dcabs1(v) + if absV > max { + max = absV + idx = i + 1 + } + } + return idx + } + ix := incX + for i := 1; i < n; i++ { + absV := dcabs1(x[ix]) + if absV > max { + max = absV + idx = i + } + ix += incX + } + return idx +} + +// Zaxpy adds alpha times x to y: +// y[i] += alpha * x[i] for all i +func (Implementation) Zaxpy(n int, alpha complex128, x []complex128, incX int, y []complex128, incY int) { + if incX == 0 { + panic(zeroIncX) + } + if incY == 0 { + panic(zeroIncY) + } + if n < 1 { + if n == 0 { + return + } + panic(negativeN) + } + if (incX > 0 && (n-1)*incX >= len(x)) || (incX < 0 && (1-n)*incX >= len(x)) { + panic(badX) + } + if (incY > 0 && (n-1)*incY >= len(y)) || (incY < 0 && (1-n)*incY >= len(y)) { + panic(badY) + } + if alpha == 0 { + return + } + if incX == 1 && incY == 1 { + c128.AxpyUnitary(alpha, x[:n], y[:n]) + return + } + var ix, iy int + if incX < 0 { + ix = (1 - n) * incX + } + if incY < 0 { + iy = (1 - n) * incY + } + c128.AxpyInc(alpha, x, y, uintptr(n), uintptr(incX), uintptr(incY), uintptr(ix), uintptr(iy)) +} + +// Zcopy copies the vector x to vector y. +func (Implementation) Zcopy(n int, x []complex128, incX int, y []complex128, incY int) { + if incX == 0 { + panic(zeroIncX) + } + if incY == 0 { + panic(zeroIncY) + } + if n < 1 { + if n == 0 { + return + } + panic(negativeN) + } + if (incX > 0 && (n-1)*incX >= len(x)) || (incX < 0 && (1-n)*incX >= len(x)) { + panic(badX) + } + if (incY > 0 && (n-1)*incY >= len(y)) || (incY < 0 && (1-n)*incY >= len(y)) { + panic(badY) + } + if incX == 1 && incY == 1 { + copy(y[:n], x[:n]) + return + } + var ix, iy int + if incX < 0 { + ix = (-n + 1) * incX + } + if incY < 0 { + iy = (-n + 1) * incY + } + for i := 0; i < n; i++ { + y[iy] = x[ix] + ix += incX + iy += incY + } +} + +// Zdotc computes the dot product +// x^H · y +// of two complex vectors x and y. +func (Implementation) Zdotc(n int, x []complex128, incX int, y []complex128, incY int) complex128 { + if incX == 0 { + panic(zeroIncX) + } + if incY == 0 { + panic(zeroIncY) + } + if n <= 0 { + if n == 0 { + return 0 + } + panic(negativeN) + } + if incX == 1 && incY == 1 { + if len(x) < n { + panic(badX) + } + if len(y) < n { + panic(badY) + } + return c128.DotcUnitary(x[:n], y[:n]) + } + var ix, iy int + if incX < 0 { + ix = (-n + 1) * incX + } + if incY < 0 { + iy = (-n + 1) * incY + } + if ix >= len(x) || (n-1)*incX >= len(x) { + panic(badX) + } + if iy >= len(y) || (n-1)*incY >= len(y) { + panic(badY) + } + return c128.DotcInc(x, y, uintptr(n), uintptr(incX), uintptr(incY), uintptr(ix), uintptr(iy)) +} + +// Zdotu computes the dot product +// x^T · y +// of two complex vectors x and y. +func (Implementation) Zdotu(n int, x []complex128, incX int, y []complex128, incY int) complex128 { + if incX == 0 { + panic(zeroIncX) + } + if incY == 0 { + panic(zeroIncY) + } + if n <= 0 { + if n == 0 { + return 0 + } + panic(negativeN) + } + if incX == 1 && incY == 1 { + if len(x) < n { + panic(badX) + } + if len(y) < n { + panic(badY) + } + return c128.DotuUnitary(x[:n], y[:n]) + } + var ix, iy int + if incX < 0 { + ix = (-n + 1) * incX + } + if incY < 0 { + iy = (-n + 1) * incY + } + if ix >= len(x) || (n-1)*incX >= len(x) { + panic(badX) + } + if iy >= len(y) || (n-1)*incY >= len(y) { + panic(badY) + } + return c128.DotuInc(x, y, uintptr(n), uintptr(incX), uintptr(incY), uintptr(ix), uintptr(iy)) +} + +// Zdscal scales the vector x by a real scalar alpha. +// Zdscal has no effect if incX < 0. +func (Implementation) Zdscal(n int, alpha float64, x []complex128, incX int) { + if incX < 1 { + if incX == 0 { + panic(zeroIncX) + } + return + } + if (n-1)*incX >= len(x) { + panic(badX) + } + if n < 1 { + if n == 0 { + return + } + panic(negativeN) + } + if alpha == 0 { + if incX == 1 { + x = x[:n] + for i := range x { + x[i] = 0 + } + return + } + for ix := 0; ix < n*incX; ix += incX { + x[ix] = 0 + } + return + } + if incX == 1 { + x = x[:n] + for i, v := range x { + x[i] = complex(alpha*real(v), alpha*imag(v)) + } + return + } + for ix := 0; ix < n*incX; ix += incX { + v := x[ix] + x[ix] = complex(alpha*real(v), alpha*imag(v)) + } +} + +// Zscal scales the vector x by a complex scalar alpha. +// Zscal has no effect if incX < 0. +func (Implementation) Zscal(n int, alpha complex128, x []complex128, incX int) { + if incX < 1 { + if incX == 0 { + panic(zeroIncX) + } + return + } + if (n-1)*incX >= len(x) { + panic(badX) + } + if n < 1 { + if n == 0 { + return + } + panic(negativeN) + } + if alpha == 0 { + if incX == 1 { + x = x[:n] + for i := range x { + x[i] = 0 + } + return + } + for ix := 0; ix < n*incX; ix += incX { + x[ix] = 0 + } + return + } + if incX == 1 { + c128.ScalUnitary(alpha, x[:n]) + return + } + c128.ScalInc(alpha, x, uintptr(n), uintptr(incX)) +} + +// Zswap exchanges the elements of two complex vectors x and y. +func (Implementation) Zswap(n int, x []complex128, incX int, y []complex128, incY int) { + if incX == 0 { + panic(zeroIncX) + } + if incY == 0 { + panic(zeroIncY) + } + if n < 1 { + if n == 0 { + return + } + panic(negativeN) + } + if (incX > 0 && (n-1)*incX >= len(x)) || (incX < 0 && (1-n)*incX >= len(x)) { + panic(badX) + } + if (incY > 0 && (n-1)*incY >= len(y)) || (incY < 0 && (1-n)*incY >= len(y)) { + panic(badY) + } + if incX == 1 && incY == 1 { + x = x[:n] + for i, v := range x { + x[i], y[i] = y[i], v + } + return + } + var ix, iy int + if incX < 0 { + ix = (-n + 1) * incX + } + if incY < 0 { + iy = (-n + 1) * incY + } + for i := 0; i < n; i++ { + x[ix], y[iy] = y[iy], x[ix] + ix += incX + iy += incY + } +} diff --git a/vendor/github.com/gonum/blas/native/level1double.go b/vendor/gonum.org/v1/gonum/blas/gonum/level1double.go similarity index 96% rename from vendor/github.com/gonum/blas/native/level1double.go rename to vendor/gonum.org/v1/gonum/blas/gonum/level1double.go index 6aa46e33..d24483a1 100644 --- a/vendor/github.com/gonum/blas/native/level1double.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level1double.go @@ -1,14 +1,14 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/internal/asm/f64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/internal/asm/f64" ) var _ blas.Float64Level1 = Implementation{} @@ -270,13 +270,7 @@ func (Implementation) Daxpy(n int, alpha float64, x []float64, incX int, y []flo return } if incX == 1 && incY == 1 { - if len(x) < n { - panic(badLenX) - } - if len(y) < n { - panic(badLenY) - } - f64.AxpyUnitaryTo(y, alpha, x[:n], y) + f64.AxpyUnitary(alpha, x[:n], y[:n]) return } var ix, iy int @@ -286,12 +280,6 @@ func (Implementation) Daxpy(n int, alpha float64, x []float64, incX int, y []flo if incY < 0 { iy = (-n + 1) * incY } - if ix >= len(x) || ix+(n-1)*incX >= len(x) { - panic(badLenX) - } - if iy >= len(y) || iy+(n-1)*incY >= len(y) { - panic(badLenY) - } f64.AxpyInc(alpha, x, y, uintptr(n), uintptr(incX), uintptr(incY), uintptr(ix), uintptr(iy)) } @@ -565,7 +553,6 @@ func (Implementation) Drotm(n int, x []float64, incX int, y []float64, incY int, ix += incX iy += incY } - return } // Dscal scales x by alpha. @@ -604,7 +591,5 @@ func (Implementation) Dscal(n int, alpha float64, x []float64, incX int) { f64.ScalUnitary(alpha, x[:n]) return } - for ix := 0; ix < n*incX; ix += incX { - x[ix] *= alpha - } + f64.ScalInc(alpha, x, uintptr(n), uintptr(incX)) } diff --git a/vendor/github.com/gonum/blas/native/level1double_ddot.go b/vendor/gonum.org/v1/gonum/blas/gonum/level1double_ddot.go similarity index 88% rename from vendor/github.com/gonum/blas/native/level1double_ddot.go rename to vendor/gonum.org/v1/gonum/blas/gonum/level1double_ddot.go index 03e66a0a..2b44fe92 100644 --- a/vendor/github.com/gonum/blas/native/level1double_ddot.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level1double_ddot.go @@ -1,11 +1,11 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/internal/asm/f64" + "gonum.org/v1/gonum/internal/asm/f64" ) // Ddot computes the dot product of the two vectors diff --git a/vendor/github.com/gonum/blas/native/level1single.go b/vendor/gonum.org/v1/gonum/blas/gonum/level1single.go similarity index 95% rename from vendor/github.com/gonum/blas/native/level1single.go rename to vendor/gonum.org/v1/gonum/blas/gonum/level1single.go index 046a4410..ce26ef33 100644 --- a/vendor/github.com/gonum/blas/native/level1single.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level1single.go @@ -1,16 +1,16 @@ -// Code generated by "go generate github.com/gonum/blas/native"; DO NOT EDIT. +// Code generated by "go generate gonum.org/v1/gonum/blas/gonum”; DO NOT EDIT. -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - math "github.com/gonum/blas/native/internal/math32" + math "gonum.org/v1/gonum/internal/math32" - "github.com/gonum/blas" - "github.com/gonum/internal/asm/f32" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/internal/asm/f32" ) var _ blas.Float32Level1 = Implementation{} @@ -284,13 +284,7 @@ func (Implementation) Saxpy(n int, alpha float32, x []float32, incX int, y []flo return } if incX == 1 && incY == 1 { - if len(x) < n { - panic(badLenX) - } - if len(y) < n { - panic(badLenY) - } - f32.AxpyUnitaryTo(y, alpha, x[:n], y) + f32.AxpyUnitary(alpha, x[:n], y[:n]) return } var ix, iy int @@ -300,12 +294,6 @@ func (Implementation) Saxpy(n int, alpha float32, x []float32, incX int, y []flo if incY < 0 { iy = (-n + 1) * incY } - if ix >= len(x) || ix+(n-1)*incX >= len(x) { - panic(badLenX) - } - if iy >= len(y) || iy+(n-1)*incY >= len(y) { - panic(badLenY) - } f32.AxpyInc(alpha, x, y, uintptr(n), uintptr(incX), uintptr(incY), uintptr(ix), uintptr(iy)) } @@ -587,7 +575,6 @@ func (Implementation) Srotm(n int, x []float32, incX int, y []float32, incY int, ix += incX iy += incY } - return } // Sscal scales x by alpha. @@ -628,7 +615,5 @@ func (Implementation) Sscal(n int, alpha float32, x []float32, incX int) { f32.ScalUnitary(alpha, x[:n]) return } - for ix := 0; ix < n*incX; ix += incX { - x[ix] *= alpha - } + f32.ScalInc(alpha, x, uintptr(n), uintptr(incX)) } diff --git a/vendor/github.com/gonum/blas/native/level1single_dsdot.go b/vendor/gonum.org/v1/gonum/blas/gonum/level1single_dsdot.go similarity index 83% rename from vendor/github.com/gonum/blas/native/level1single_dsdot.go rename to vendor/gonum.org/v1/gonum/blas/gonum/level1single_dsdot.go index a60f81b8..d69d0d66 100644 --- a/vendor/github.com/gonum/blas/native/level1single_dsdot.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level1single_dsdot.go @@ -1,13 +1,13 @@ -// Code generated by "go generate github.com/gonum/blas/native"; DO NOT EDIT. +// Code generated by "go generate gonum.org/v1/gonum/blas/gonum”; DO NOT EDIT. -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/internal/asm/f32" + "gonum.org/v1/gonum/internal/asm/f32" ) // Dsdot computes the dot product of the two vectors diff --git a/vendor/github.com/gonum/blas/native/level1single_sdot.go b/vendor/gonum.org/v1/gonum/blas/gonum/level1single_sdot.go similarity index 83% rename from vendor/github.com/gonum/blas/native/level1single_sdot.go rename to vendor/gonum.org/v1/gonum/blas/gonum/level1single_sdot.go index ccce03d5..c2e25150 100644 --- a/vendor/github.com/gonum/blas/native/level1single_sdot.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level1single_sdot.go @@ -1,13 +1,13 @@ -// Code generated by "go generate github.com/gonum/blas/native"; DO NOT EDIT. +// Code generated by "go generate gonum.org/v1/gonum/blas/gonum”; DO NOT EDIT. -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/internal/asm/f32" + "gonum.org/v1/gonum/internal/asm/f32" ) // Sdot computes the dot product of the two vectors diff --git a/vendor/github.com/gonum/blas/native/level1single_sdsdot.go b/vendor/gonum.org/v1/gonum/blas/gonum/level1single_sdsdot.go similarity index 84% rename from vendor/github.com/gonum/blas/native/level1single_sdsdot.go rename to vendor/gonum.org/v1/gonum/blas/gonum/level1single_sdsdot.go index b4f04691..4315a122 100644 --- a/vendor/github.com/gonum/blas/native/level1single_sdsdot.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level1single_sdsdot.go @@ -1,13 +1,13 @@ -// Code generated by "go generate github.com/gonum/blas/native"; DO NOT EDIT. +// Code generated by "go generate gonum.org/v1/gonum/blas/gonum”; DO NOT EDIT. -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/internal/asm/f32" + "gonum.org/v1/gonum/internal/asm/f32" ) // Sdsdot computes the dot product of the two vectors plus a constant diff --git a/vendor/gonum.org/v1/gonum/blas/gonum/level2cmplx128.go b/vendor/gonum.org/v1/gonum/blas/gonum/level2cmplx128.go new file mode 100644 index 00000000..06fe13bd --- /dev/null +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level2cmplx128.go @@ -0,0 +1,1321 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gonum + +import ( + "math/cmplx" + + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/internal/asm/c128" +) + +// Zgemv performs one of the matrix-vector operations +// y = alpha * A * x + beta * y if trans = blas.NoTrans +// y = alpha * A^T * x + beta * y if trans = blas.Trans +// y = alpha * A^H * x + beta * y if trans = blas.ConjTrans +// where alpha and beta are scalars, x and y are vectors, and A is an m×n dense matrix. +func (Implementation) Zgemv(trans blas.Transpose, m, n int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int) { + checkZMatrix('A', m, n, a, lda) + switch trans { + default: + panic(badTranspose) + case blas.NoTrans: + checkZVector('x', n, x, incX) + checkZVector('y', m, y, incY) + case blas.Trans, blas.ConjTrans: + checkZVector('x', m, x, incX) + checkZVector('y', n, y, incY) + } + + if m == 0 || n == 0 || (alpha == 0 && beta == 1) { + return + } + + var lenX, lenY int + if trans == blas.NoTrans { + lenX = n + lenY = m + } else { + lenX = m + lenY = n + } + var kx int + if incX < 0 { + kx = (1 - lenX) * incX + } + var ky int + if incY < 0 { + ky = (1 - lenY) * incY + } + + // Form y := beta*y. + if beta != 1 { + if incY == 1 { + if beta == 0 { + for i := range y[:lenY] { + y[i] = 0 + } + } else { + c128.ScalUnitary(beta, y[:lenY]) + } + } else { + iy := ky + if beta == 0 { + for i := 0; i < lenY; i++ { + y[iy] = 0 + iy += incY + } + } else { + if incY > 0 { + c128.ScalInc(beta, y, uintptr(lenY), uintptr(incY)) + } else { + c128.ScalInc(beta, y, uintptr(lenY), uintptr(-incY)) + } + } + } + } + + if alpha == 0 { + return + } + + switch trans { + default: + // Form y := alpha*A*x + y. + iy := ky + if incX == 1 { + for i := 0; i < m; i++ { + y[iy] += alpha * c128.DotuUnitary(a[i*lda:i*lda+n], x[:n]) + iy += incY + } + return + } + for i := 0; i < m; i++ { + y[iy] += alpha * c128.DotuInc(a[i*lda:i*lda+n], x, uintptr(n), 1, uintptr(incX), 0, uintptr(kx)) + iy += incY + } + return + + case blas.Trans: + // Form y := alpha*A^T*x + y. + ix := kx + if incY == 1 { + for i := 0; i < m; i++ { + c128.AxpyUnitary(alpha*x[ix], a[i*lda:i*lda+n], y[:n]) + ix += incX + } + return + } + for i := 0; i < m; i++ { + c128.AxpyInc(alpha*x[ix], a[i*lda:i*lda+n], y, uintptr(n), 1, uintptr(incY), 0, uintptr(ky)) + ix += incX + } + return + + case blas.ConjTrans: + // Form y := alpha*A^H*x + y. + ix := kx + if incY == 1 { + for i := 0; i < m; i++ { + tmp := alpha * x[ix] + for j := 0; j < n; j++ { + y[j] += tmp * cmplx.Conj(a[i*lda+j]) + } + ix += incX + } + return + } + for i := 0; i < m; i++ { + tmp := alpha * x[ix] + jy := ky + for j := 0; j < n; j++ { + y[jy] += tmp * cmplx.Conj(a[i*lda+j]) + jy += incY + } + ix += incX + } + return + } +} + +// Zgerc performs the rank-one operation +// A += alpha * x * y^H +// where A is an m×n dense matrix, alpha is a scalar, x is an m element vector, +// and y is an n element vector. +func (Implementation) Zgerc(m, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int) { + checkZMatrix('A', m, n, a, lda) + checkZVector('x', m, x, incX) + checkZVector('y', n, y, incY) + + if m == 0 || n == 0 || alpha == 0 { + return + } + + var kx, jy int + if incX < 0 { + kx = (1 - m) * incX + } + if incY < 0 { + jy = (1 - n) * incY + } + for j := 0; j < n; j++ { + if y[jy] != 0 { + tmp := alpha * cmplx.Conj(y[jy]) + c128.AxpyInc(tmp, x, a[j:], uintptr(m), uintptr(incX), uintptr(lda), uintptr(kx), 0) + } + jy += incY + } +} + +// Zgeru performs the rank-one operation +// A += alpha * x * y^T +// where A is an m×n dense matrix, alpha is a scalar, x is an m element vector, +// and y is an n element vector. +func (Implementation) Zgeru(m, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int) { + checkZMatrix('A', m, n, a, lda) + checkZVector('x', m, x, incX) + checkZVector('y', n, y, incY) + + if m == 0 || n == 0 || alpha == 0 { + return + } + + var kx int + if incX < 0 { + kx = (1 - m) * incX + } + if incY == 1 { + for i := 0; i < m; i++ { + if x[kx] != 0 { + tmp := alpha * x[kx] + c128.AxpyUnitary(tmp, y[:n], a[i*lda:i*lda+n]) + } + kx += incX + } + return + } + var jy int + if incY < 0 { + jy = (1 - n) * incY + } + for i := 0; i < m; i++ { + if x[kx] != 0 { + tmp := alpha * x[kx] + c128.AxpyInc(tmp, y, a[i*lda:i*lda+n], uintptr(n), uintptr(incY), 1, uintptr(jy), 0) + } + kx += incX + } +} + +// Zhemv performs the matrix-vector operation +// y = alpha * A * x + beta * y +// where alpha and beta are scalars, x and y are vectors, and A is an n×n +// Hermitian matrix. The imaginary parts of the diagonal elements of A are +// ignored and assumed to be zero. +func (Implementation) Zhemv(uplo blas.Uplo, n int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int) { + if uplo != blas.Upper && uplo != blas.Lower { + panic(badUplo) + } + checkZMatrix('A', n, n, a, lda) + checkZVector('x', n, x, incX) + checkZVector('y', n, y, incY) + + if n == 0 || (alpha == 0 && beta == 1) { + return + } + + // Set up the start indices in X and Y. + var kx int + if incX < 0 { + kx = (1 - n) * incX + } + var ky int + if incY < 0 { + ky = (1 - n) * incY + } + + // Form y := beta*y. + if beta != 1 { + if incY == 1 { + if beta == 0 { + for i := range y[:n] { + y[i] = 0 + } + } else { + for i, v := range y[:n] { + y[i] = beta * v + } + } + } else { + iy := ky + if beta == 0 { + for i := 0; i < n; i++ { + y[iy] = 0 + iy += incY + } + } else { + for i := 0; i < n; i++ { + y[iy] = beta * y[iy] + iy += incY + } + } + } + } + + if alpha == 0 { + return + } + + // The elements of A are accessed sequentially with one pass through + // the triangular part of A. + + if uplo == blas.Upper { + // Form y when A is stored in upper triangle. + if incX == 1 && incY == 1 { + for i := 0; i < n; i++ { + tmp1 := alpha * x[i] + var tmp2 complex128 + for j := i + 1; j < n; j++ { + y[j] += tmp1 * cmplx.Conj(a[i*lda+j]) + tmp2 += a[i*lda+j] * x[j] + } + aii := complex(real(a[i*lda+i]), 0) + y[i] += tmp1*aii + alpha*tmp2 + } + } else { + ix := kx + iy := ky + for i := 0; i < n; i++ { + tmp1 := alpha * x[ix] + var tmp2 complex128 + jx := ix + jy := iy + for j := i + 1; j < n; j++ { + jx += incX + jy += incY + y[jy] += tmp1 * cmplx.Conj(a[i*lda+j]) + tmp2 += a[i*lda+j] * x[jx] + } + aii := complex(real(a[i*lda+i]), 0) + y[iy] += tmp1*aii + alpha*tmp2 + ix += incX + iy += incY + } + } + return + } + + // Form y when A is stored in lower triangle. + if incX == 1 && incY == 1 { + for i := 0; i < n; i++ { + tmp1 := alpha * x[i] + var tmp2 complex128 + for j := 0; j < i; j++ { + y[j] += tmp1 * cmplx.Conj(a[i*lda+j]) + tmp2 += a[i*lda+j] * x[j] + } + aii := complex(real(a[i*lda+i]), 0) + y[i] += tmp1*aii + alpha*tmp2 + } + } else { + ix := kx + iy := ky + for i := 0; i < n; i++ { + tmp1 := alpha * x[ix] + var tmp2 complex128 + jx := kx + jy := ky + for j := 0; j < i; j++ { + y[jy] += tmp1 * cmplx.Conj(a[i*lda+j]) + tmp2 += a[i*lda+j] * x[jx] + jx += incX + jy += incY + } + aii := complex(real(a[i*lda+i]), 0) + y[iy] += tmp1*aii + alpha*tmp2 + ix += incX + iy += incY + } + } +} + +// Zher performs the Hermitian rank-one operation +// A += alpha * x * x^H +// where A is an n×n Hermitian matrix, alpha is a real scalar, and x is an n +// element vector. On entry, the imaginary parts of the diagonal elements of A +// are ignored and assumed to be zero, on return they will be set to zero. +func (Implementation) Zher(uplo blas.Uplo, n int, alpha float64, x []complex128, incX int, a []complex128, lda int) { + if uplo != blas.Upper && uplo != blas.Lower { + panic(badUplo) + } + checkZMatrix('A', n, n, a, lda) + checkZVector('x', n, x, incX) + + if n == 0 || alpha == 0 { + return + } + + var kx int + if incX < 0 { + kx = (1 - n) * incX + } + if uplo == blas.Upper { + if incX == 1 { + for i := 0; i < n; i++ { + if x[i] != 0 { + tmp := complex(alpha*real(x[i]), alpha*imag(x[i])) + aii := real(a[i*lda+i]) + xtmp := real(tmp * cmplx.Conj(x[i])) + a[i*lda+i] = complex(aii+xtmp, 0) + for j := i + 1; j < n; j++ { + a[i*lda+j] += tmp * cmplx.Conj(x[j]) + } + } else { + aii := real(a[i*lda+i]) + a[i*lda+i] = complex(aii, 0) + } + } + return + } + + ix := kx + for i := 0; i < n; i++ { + if x[ix] != 0 { + tmp := complex(alpha*real(x[ix]), alpha*imag(x[ix])) + aii := real(a[i*lda+i]) + xtmp := real(tmp * cmplx.Conj(x[ix])) + a[i*lda+i] = complex(aii+xtmp, 0) + jx := ix + incX + for j := i + 1; j < n; j++ { + a[i*lda+j] += tmp * cmplx.Conj(x[jx]) + jx += incX + } + } else { + aii := real(a[i*lda+i]) + a[i*lda+i] = complex(aii, 0) + } + ix += incX + } + return + } + + if incX == 1 { + for i := 0; i < n; i++ { + if x[i] != 0 { + tmp := complex(alpha*real(x[i]), alpha*imag(x[i])) + for j := 0; j < i; j++ { + a[i*lda+j] += tmp * cmplx.Conj(x[j]) + } + aii := real(a[i*lda+i]) + xtmp := real(tmp * cmplx.Conj(x[i])) + a[i*lda+i] = complex(aii+xtmp, 0) + } else { + aii := real(a[i*lda+i]) + a[i*lda+i] = complex(aii, 0) + } + } + return + } + + ix := kx + for i := 0; i < n; i++ { + if x[ix] != 0 { + tmp := complex(alpha*real(x[ix]), alpha*imag(x[ix])) + jx := kx + for j := 0; j < i; j++ { + a[i*lda+j] += tmp * cmplx.Conj(x[jx]) + jx += incX + } + aii := real(a[i*lda+i]) + xtmp := real(tmp * cmplx.Conj(x[ix])) + a[i*lda+i] = complex(aii+xtmp, 0) + + } else { + aii := real(a[i*lda+i]) + a[i*lda+i] = complex(aii, 0) + } + ix += incX + } +} + +// Zher2 performs the Hermitian rank-two operation +// A += alpha*x*y^H + conj(alpha)*y*x^H +// where alpha is a scalar, x and y are n element vectors and A is an n×n +// Hermitian matrix. On entry, the imaginary parts of the diagonal elements are +// ignored and assumed to be zero. On return they will be set to zero. +func (Implementation) Zher2(uplo blas.Uplo, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int) { + if uplo != blas.Upper && uplo != blas.Lower { + panic(badUplo) + } + checkZMatrix('A', n, n, a, lda) + checkZVector('x', n, x, incX) + checkZVector('y', n, y, incY) + + if n == 0 || alpha == 0 { + return + } + + var kx, ky int + var ix, iy int + if incX != 1 || incY != 1 { + if incX < 0 { + kx = (1 - n) * incX + } + if incY < 0 { + ky = (1 - n) * incY + } + ix = kx + iy = ky + } + if uplo == blas.Upper { + if incX == 1 && incY == 1 { + for i := 0; i < n; i++ { + if x[i] != 0 || y[i] != 0 { + tmp1 := alpha * x[i] + tmp2 := cmplx.Conj(alpha) * y[i] + aii := real(a[i*lda+i]) + real(tmp1*cmplx.Conj(y[i])) + real(tmp2*cmplx.Conj(x[i])) + a[i*lda+i] = complex(aii, 0) + for j := i + 1; j < n; j++ { + a[i*lda+j] += tmp1*cmplx.Conj(y[j]) + tmp2*cmplx.Conj(x[j]) + } + } else { + aii := real(a[i*lda+i]) + a[i*lda+i] = complex(aii, 0) + } + } + return + } + for i := 0; i < n; i++ { + if x[ix] != 0 || y[iy] != 0 { + tmp1 := alpha * x[ix] + tmp2 := cmplx.Conj(alpha) * y[iy] + aii := real(a[i*lda+i]) + real(tmp1*cmplx.Conj(y[iy])) + real(tmp2*cmplx.Conj(x[ix])) + a[i*lda+i] = complex(aii, 0) + jx := ix + incX + jy := iy + incY + for j := i + 1; j < n; j++ { + a[i*lda+j] += tmp1*cmplx.Conj(y[jy]) + tmp2*cmplx.Conj(x[jx]) + jx += incX + jy += incY + } + } else { + aii := real(a[i*lda+i]) + a[i*lda+i] = complex(aii, 0) + } + ix += incX + iy += incY + } + return + } + + if incX == 1 && incY == 1 { + for i := 0; i < n; i++ { + if x[i] != 0 || y[i] != 0 { + tmp1 := alpha * x[i] + tmp2 := cmplx.Conj(alpha) * y[i] + for j := 0; j < i; j++ { + a[i*lda+j] += tmp1*cmplx.Conj(y[j]) + tmp2*cmplx.Conj(x[j]) + } + aii := real(a[i*lda+i]) + real(tmp1*cmplx.Conj(y[i])) + real(tmp2*cmplx.Conj(x[i])) + a[i*lda+i] = complex(aii, 0) + } else { + aii := real(a[i*lda+i]) + a[i*lda+i] = complex(aii, 0) + } + } + return + } + for i := 0; i < n; i++ { + if x[ix] != 0 || y[iy] != 0 { + tmp1 := alpha * x[ix] + tmp2 := cmplx.Conj(alpha) * y[iy] + jx := kx + jy := ky + for j := 0; j < i; j++ { + a[i*lda+j] += tmp1*cmplx.Conj(y[jy]) + tmp2*cmplx.Conj(x[jx]) + jx += incX + jy += incY + } + aii := real(a[i*lda+i]) + real(tmp1*cmplx.Conj(y[iy])) + real(tmp2*cmplx.Conj(x[ix])) + a[i*lda+i] = complex(aii, 0) + } else { + aii := real(a[i*lda+i]) + a[i*lda+i] = complex(aii, 0) + } + ix += incX + iy += incY + } +} + +// Zhpmv performs the matrix-vector operation +// y = alpha * A * x + beta * y +// where alpha and beta are scalars, x and y are vectors, and A is an n×n +// Hermitian matrix in packed form. The imaginary parts of the diagonal +// elements of A are ignored and assumed to be zero. +func (Implementation) Zhpmv(uplo blas.Uplo, n int, alpha complex128, ap []complex128, x []complex128, incX int, beta complex128, y []complex128, incY int) { + if uplo != blas.Upper && uplo != blas.Lower { + panic(badUplo) + } + checkZVector('x', n, x, incX) + checkZVector('y', n, y, incY) + if len(ap) < n*(n+1)/2 { + panic("blas: insufficient A packed matrix slice length") + } + + if n == 0 || (alpha == 0 && beta == 1) { + return + } + + // Set up the start indices in X and Y. + var kx int + if incX < 0 { + kx = (1 - n) * incX + } + var ky int + if incY < 0 { + ky = (1 - n) * incY + } + + // Form y := beta*y. + if beta != 1 { + if incY == 1 { + if beta == 0 { + for i := range y[:n] { + y[i] = 0 + } + } else { + for i, v := range y[:n] { + y[i] = beta * v + } + } + } else { + iy := ky + if beta == 0 { + for i := 0; i < n; i++ { + y[iy] = 0 + iy += incY + } + } else { + for i := 0; i < n; i++ { + y[iy] *= beta + iy += incY + } + } + } + } + + if alpha == 0 { + return + } + + // The elements of A are accessed sequentially with one pass through ap. + + var kk int + if uplo == blas.Upper { + // Form y when ap contains the upper triangle. + // Here, kk points to the current diagonal element in ap. + if incX == 1 && incY == 1 { + for i := 0; i < n; i++ { + tmp1 := alpha * x[i] + y[i] += tmp1 * complex(real(ap[kk]), 0) + var tmp2 complex128 + k := kk + 1 + for j := i + 1; j < n; j++ { + y[j] += tmp1 * cmplx.Conj(ap[k]) + tmp2 += ap[k] * x[j] + k++ + } + y[i] += alpha * tmp2 + kk += n - i + } + } else { + ix := kx + iy := ky + for i := 0; i < n; i++ { + tmp1 := alpha * x[ix] + y[iy] += tmp1 * complex(real(ap[kk]), 0) + var tmp2 complex128 + jx := ix + jy := iy + for k := kk + 1; k < kk+n-i; k++ { + jx += incX + jy += incY + y[jy] += tmp1 * cmplx.Conj(ap[k]) + tmp2 += ap[k] * x[jx] + } + y[iy] += alpha * tmp2 + ix += incX + iy += incY + kk += n - i + } + } + return + } + + // Form y when ap contains the lower triangle. + // Here, kk points to the beginning of current row in ap. + if incX == 1 && incY == 1 { + for i := 0; i < n; i++ { + tmp1 := alpha * x[i] + var tmp2 complex128 + k := kk + for j := 0; j < i; j++ { + y[j] += tmp1 * cmplx.Conj(ap[k]) + tmp2 += ap[k] * x[j] + k++ + } + aii := complex(real(ap[kk+i]), 0) + y[i] += tmp1*aii + alpha*tmp2 + kk += i + 1 + } + } else { + ix := kx + iy := ky + for i := 0; i < n; i++ { + tmp1 := alpha * x[ix] + var tmp2 complex128 + jx := kx + jy := ky + for k := kk; k < kk+i; k++ { + y[jy] += tmp1 * cmplx.Conj(ap[k]) + tmp2 += ap[k] * x[jx] + jx += incX + jy += incY + } + aii := complex(real(ap[kk+i]), 0) + y[iy] += tmp1*aii + alpha*tmp2 + ix += incX + iy += incY + kk += i + 1 + } + } +} + +// Zhpr performs the Hermitian rank-1 operation +// A += alpha * x * x^H, +// where alpha is a real scalar, x is a vector, and A is an n×n hermitian matrix +// in packed form. On entry, the imaginary parts of the diagonal elements are +// assumed to be zero, and on return they are set to zero. +func (Implementation) Zhpr(uplo blas.Uplo, n int, alpha float64, x []complex128, incX int, ap []complex128) { + if uplo != blas.Upper && uplo != blas.Lower { + panic(badUplo) + } + if n < 0 { + panic(nLT0) + } + checkZVector('x', n, x, incX) + if len(ap) < n*(n+1)/2 { + panic("blas: insufficient A packed matrix slice length") + } + + if n == 0 || alpha == 0 { + return + } + + // Set up start index in X. + var kx int + if incX < 0 { + kx = (1 - n) * incX + } + + // The elements of A are accessed sequentially with one pass through ap. + + var kk int + if uplo == blas.Upper { + // Form A when upper triangle is stored in AP. + // Here, kk points to the current diagonal element in ap. + if incX == 1 { + for i := 0; i < n; i++ { + xi := x[i] + if xi != 0 { + aii := real(ap[kk]) + alpha*real(cmplx.Conj(xi)*xi) + ap[kk] = complex(aii, 0) + + tmp := complex(alpha, 0) * xi + a := ap[kk+1 : kk+n-i] + x := x[i+1 : n] + for j, v := range x { + a[j] += tmp * cmplx.Conj(v) + } + } else { + ap[kk] = complex(real(ap[kk]), 0) + } + kk += n - i + } + } else { + ix := kx + for i := 0; i < n; i++ { + xi := x[ix] + if xi != 0 { + aii := real(ap[kk]) + alpha*real(cmplx.Conj(xi)*xi) + ap[kk] = complex(aii, 0) + + tmp := complex(alpha, 0) * xi + jx := ix + incX + a := ap[kk+1 : kk+n-i] + for k := range a { + a[k] += tmp * cmplx.Conj(x[jx]) + jx += incX + } + } else { + ap[kk] = complex(real(ap[kk]), 0) + } + ix += incX + kk += n - i + } + } + return + } + + // Form A when lower triangle is stored in AP. + // Here, kk points to the beginning of current row in ap. + if incX == 1 { + for i := 0; i < n; i++ { + xi := x[i] + if xi != 0 { + tmp := complex(alpha, 0) * xi + a := ap[kk : kk+i] + for j, v := range x[:i] { + a[j] += tmp * cmplx.Conj(v) + } + + aii := real(ap[kk+i]) + alpha*real(cmplx.Conj(xi)*xi) + ap[kk+i] = complex(aii, 0) + } else { + ap[kk+i] = complex(real(ap[kk+i]), 0) + } + kk += i + 1 + } + } else { + ix := kx + for i := 0; i < n; i++ { + xi := x[ix] + if xi != 0 { + tmp := complex(alpha, 0) * xi + a := ap[kk : kk+i] + jx := kx + for k := range a { + a[k] += tmp * cmplx.Conj(x[jx]) + jx += incX + } + + aii := real(ap[kk+i]) + alpha*real(cmplx.Conj(xi)*xi) + ap[kk+i] = complex(aii, 0) + } else { + ap[kk+i] = complex(real(ap[kk+i]), 0) + } + ix += incX + kk += i + 1 + } + } +} + +// Zhpr2 performs the Hermitian rank-2 operation +// A += alpha*x*y^H + conj(alpha)*y*x^H, +// where alpha is a complex scalar, x and y are n element vectors, and A is an +// n×n Hermitian matrix, supplied in packed form. On entry, the imaginary parts +// of the diagonal elements are assumed to be zero, and on return they are set to zero. +func (Implementation) Zhpr2(uplo blas.Uplo, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, ap []complex128) { + if uplo != blas.Upper && uplo != blas.Lower { + panic(badUplo) + } + if n < 0 { + panic(nLT0) + } + checkZVector('x', n, x, incX) + checkZVector('y', n, y, incY) + if len(ap) < n*(n+1)/2 { + panic("blas: insufficient A packed matrix slice length") + } + + if n == 0 || alpha == 0 { + return + } + + // Set up start indices in X and Y. + var kx int + if incX < 0 { + kx = (1 - n) * incX + } + var ky int + if incY < 0 { + ky = (1 - n) * incY + } + + // The elements of A are accessed sequentially with one pass through ap. + + var kk int + if uplo == blas.Upper { + // Form A when upper triangle is stored in AP. + // Here, kk points to the current diagonal element in ap. + if incX == 1 && incY == 1 { + for i := 0; i < n; i++ { + if x[i] != 0 || y[i] != 0 { + tmp1 := alpha * x[i] + tmp2 := cmplx.Conj(alpha) * y[i] + aii := real(ap[kk]) + real(tmp1*cmplx.Conj(y[i])) + real(tmp2*cmplx.Conj(x[i])) + ap[kk] = complex(aii, 0) + k := kk + 1 + for j := i + 1; j < n; j++ { + ap[k] += tmp1*cmplx.Conj(y[j]) + tmp2*cmplx.Conj(x[j]) + k++ + } + } else { + ap[kk] = complex(real(ap[kk]), 0) + } + kk += n - i + } + } else { + ix := kx + iy := ky + for i := 0; i < n; i++ { + if x[ix] != 0 || y[iy] != 0 { + tmp1 := alpha * x[ix] + tmp2 := cmplx.Conj(alpha) * y[iy] + aii := real(ap[kk]) + real(tmp1*cmplx.Conj(y[iy])) + real(tmp2*cmplx.Conj(x[ix])) + ap[kk] = complex(aii, 0) + jx := ix + incX + jy := iy + incY + for k := kk + 1; k < kk+n-i; k++ { + ap[k] += tmp1*cmplx.Conj(y[jy]) + tmp2*cmplx.Conj(x[jx]) + jx += incX + jy += incY + } + } else { + ap[kk] = complex(real(ap[kk]), 0) + } + ix += incX + iy += incY + kk += n - i + } + } + return + } + + // Form A when lower triangle is stored in AP. + // Here, kk points to the beginning of current row in ap. + if incX == 1 && incY == 1 { + for i := 0; i < n; i++ { + if x[i] != 0 || y[i] != 0 { + tmp1 := alpha * x[i] + tmp2 := cmplx.Conj(alpha) * y[i] + k := kk + for j := 0; j < i; j++ { + ap[k] += tmp1*cmplx.Conj(y[j]) + tmp2*cmplx.Conj(x[j]) + k++ + } + aii := real(ap[kk+i]) + real(tmp1*cmplx.Conj(y[i])) + real(tmp2*cmplx.Conj(x[i])) + ap[kk+i] = complex(aii, 0) + } else { + ap[kk+i] = complex(real(ap[kk+i]), 0) + } + kk += i + 1 + } + } else { + ix := kx + iy := ky + for i := 0; i < n; i++ { + if x[ix] != 0 || y[iy] != 0 { + tmp1 := alpha * x[ix] + tmp2 := cmplx.Conj(alpha) * y[iy] + jx := kx + jy := ky + for k := kk; k < kk+i; k++ { + ap[k] += tmp1*cmplx.Conj(y[jy]) + tmp2*cmplx.Conj(x[jx]) + jx += incX + jy += incY + } + aii := real(ap[kk+i]) + real(tmp1*cmplx.Conj(y[iy])) + real(tmp2*cmplx.Conj(x[ix])) + ap[kk+i] = complex(aii, 0) + } else { + ap[kk+i] = complex(real(ap[kk+i]), 0) + } + ix += incX + iy += incY + kk += i + 1 + } + } +} + +// Ztrmv performs one of the matrix-vector operations +// x = A * x if trans = blas.NoTrans +// x = A^T * x if trans = blas.Trans +// x = A^H * x if trans = blas.ConjTrans +// where x is a vector, and A is an n×n triangular matrix. +func (Implementation) Ztrmv(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n int, a []complex128, lda int, x []complex128, incX int) { + if uplo != blas.Upper && uplo != blas.Lower { + panic(badUplo) + } + if trans != blas.NoTrans && trans != blas.Trans && trans != blas.ConjTrans { + panic(badTranspose) + } + if diag != blas.Unit && diag != blas.NonUnit { + panic(badDiag) + } + checkZMatrix('A', n, n, a, lda) + checkZVector('x', n, x, incX) + + if n == 0 { + return + } + + // Set up start index in X. + var kx int + if incX < 0 { + kx = (1 - n) * incX + } + + // The elements of A are accessed sequentially with one pass through A. + + if trans == blas.NoTrans { + // Form x := A*x. + if uplo == blas.Upper { + if incX == 1 { + for i := 0; i < n; i++ { + if diag == blas.NonUnit { + x[i] *= a[i*lda+i] + } + if n-i-1 > 0 { + x[i] += c128.DotuUnitary(a[i*lda+i+1:i*lda+n], x[i+1:n]) + } + } + } else { + ix := kx + for i := 0; i < n; i++ { + if diag == blas.NonUnit { + x[ix] *= a[i*lda+i] + } + if n-i-1 > 0 { + x[ix] += c128.DotuInc(a[i*lda+i+1:i*lda+n], x, uintptr(n-i-1), 1, uintptr(incX), 0, uintptr(ix+incX)) + } + ix += incX + } + } + } else { + if incX == 1 { + for i := n - 1; i >= 0; i-- { + if diag == blas.NonUnit { + x[i] *= a[i*lda+i] + } + if i > 0 { + x[i] += c128.DotuUnitary(a[i*lda:i*lda+i], x[:i]) + } + } + } else { + ix := kx + (n-1)*incX + for i := n - 1; i >= 0; i-- { + if diag == blas.NonUnit { + x[ix] *= a[i*lda+i] + } + if i > 0 { + x[ix] += c128.DotuInc(a[i*lda:i*lda+i], x, uintptr(i), 1, uintptr(incX), 0, uintptr(kx)) + } + ix -= incX + } + } + } + return + } + + if trans == blas.Trans { + // Form x := A^T*x. + if uplo == blas.Upper { + if incX == 1 { + for i := n - 1; i >= 0; i-- { + xi := x[i] + if diag == blas.NonUnit { + x[i] *= a[i*lda+i] + } + if n-i-1 > 0 { + c128.AxpyUnitary(xi, a[i*lda+i+1:i*lda+n], x[i+1:n]) + } + } + } else { + ix := kx + (n-1)*incX + for i := n - 1; i >= 0; i-- { + xi := x[ix] + if diag == blas.NonUnit { + x[ix] *= a[i*lda+i] + } + if n-i-1 > 0 { + c128.AxpyInc(xi, a[i*lda+i+1:i*lda+n], x, uintptr(n-i-1), 1, uintptr(incX), 0, uintptr(ix+incX)) + } + ix -= incX + } + } + } else { + if incX == 1 { + for i := 0; i < n; i++ { + if i > 0 { + c128.AxpyUnitary(x[i], a[i*lda:i*lda+i], x[:i]) + } + if diag == blas.NonUnit { + x[i] *= a[i*lda+i] + } + } + } else { + ix := kx + for i := 0; i < n; i++ { + if i > 0 { + c128.AxpyInc(x[ix], a[i*lda:i*lda+i], x, uintptr(i), 1, uintptr(incX), 0, uintptr(kx)) + } + if diag == blas.NonUnit { + x[ix] *= a[i*lda+i] + } + ix += incX + } + } + } + return + } + + // Form x := A^H*x. + if uplo == blas.Upper { + if incX == 1 { + for i := n - 1; i >= 0; i-- { + xi := x[i] + if diag == blas.NonUnit { + x[i] *= cmplx.Conj(a[i*lda+i]) + } + for j := i + 1; j < n; j++ { + x[j] += xi * cmplx.Conj(a[i*lda+j]) + } + } + } else { + ix := kx + (n-1)*incX + for i := n - 1; i >= 0; i-- { + xi := x[ix] + if diag == blas.NonUnit { + x[ix] *= cmplx.Conj(a[i*lda+i]) + } + jx := ix + incX + for j := i + 1; j < n; j++ { + x[jx] += xi * cmplx.Conj(a[i*lda+j]) + jx += incX + } + ix -= incX + } + } + } else { + if incX == 1 { + for i := 0; i < n; i++ { + for j := 0; j < i; j++ { + x[j] += x[i] * cmplx.Conj(a[i*lda+j]) + } + if diag == blas.NonUnit { + x[i] *= cmplx.Conj(a[i*lda+i]) + } + } + } else { + ix := kx + for i := 0; i < n; i++ { + jx := kx + for j := 0; j < i; j++ { + x[jx] += x[ix] * cmplx.Conj(a[i*lda+j]) + jx += incX + } + if diag == blas.NonUnit { + x[ix] *= cmplx.Conj(a[i*lda+i]) + } + ix += incX + } + } + } +} + +// Ztrsv solves one of the systems of equations +// A*x = b if trans == blas.NoTrans, +// A^T*x = b, if trans == blas.Trans, +// A^H*x = b, if trans == blas.ConjTrans, +// where b and x are n element vectors and A is an n×n triangular matrix. +// +// On entry, x contains the values of b, and the solution is +// stored in-place into x. +// +// No test for singularity or near-singularity is included in this +// routine. Such tests must be performed before calling this routine. +func (Implementation) Ztrsv(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n int, a []complex128, lda int, x []complex128, incX int) { + if uplo != blas.Upper && uplo != blas.Lower { + panic(badUplo) + } + if trans != blas.NoTrans && trans != blas.Trans && trans != blas.ConjTrans { + panic(badTranspose) + } + if diag != blas.Unit && diag != blas.NonUnit { + panic(badDiag) + } + checkZMatrix('A', n, n, a, lda) + checkZVector('x', n, x, incX) + + if n == 0 { + return + } + + // Set up start index in X. + var kx int + if incX < 0 { + kx = (1 - n) * incX + } + + // The elements of A are accessed sequentially with one pass through A. + + if trans == blas.NoTrans { + // Form x := inv(A)*x. + if uplo == blas.Upper { + if incX == 1 { + for i := n - 1; i >= 0; i-- { + aii := a[i*lda+i] + if n-i-1 > 0 { + x[i] -= c128.DotuUnitary(x[i+1:n], a[i*lda+i+1:i*lda+n]) + } + if diag == blas.NonUnit { + x[i] /= aii + } + } + } else { + ix := kx + (n-1)*incX + for i := n - 1; i >= 0; i-- { + aii := a[i*lda+i] + if n-i-1 > 0 { + x[ix] -= c128.DotuInc(x, a[i*lda+i+1:i*lda+n], uintptr(n-i-1), uintptr(incX), 1, uintptr(ix+incX), 0) + } + if diag == blas.NonUnit { + x[ix] /= aii + } + ix -= incX + } + } + } else { + if incX == 1 { + for i := 0; i < n; i++ { + if i > 0 { + x[i] -= c128.DotuUnitary(x[:i], a[i*lda:i*lda+i]) + } + if diag == blas.NonUnit { + x[i] /= a[i*lda+i] + } + } + } else { + ix := kx + for i := 0; i < n; i++ { + if i > 0 { + x[ix] -= c128.DotuInc(x, a[i*lda:i*lda+i], uintptr(i), uintptr(incX), 1, uintptr(kx), 0) + } + if diag == blas.NonUnit { + x[ix] /= a[i*lda+i] + } + ix += incX + } + } + } + return + } + + if trans == blas.Trans { + // Form x := inv(A^T)*x. + if uplo == blas.Upper { + if incX == 1 { + for j := 0; j < n; j++ { + if diag == blas.NonUnit { + x[j] /= a[j*lda+j] + } + if n-j-1 > 0 { + c128.AxpyUnitary(-x[j], a[j*lda+j+1:j*lda+n], x[j+1:n]) + } + } + } else { + jx := kx + for j := 0; j < n; j++ { + if diag == blas.NonUnit { + x[jx] /= a[j*lda+j] + } + if n-j-1 > 0 { + c128.AxpyInc(-x[jx], a[j*lda+j+1:j*lda+n], x, uintptr(n-j-1), 1, uintptr(incX), 0, uintptr(jx+incX)) + } + jx += incX + } + } + } else { + if incX == 1 { + for j := n - 1; j >= 0; j-- { + if diag == blas.NonUnit { + x[j] /= a[j*lda+j] + } + xj := x[j] + if j > 0 { + c128.AxpyUnitary(-xj, a[j*lda:j*lda+j], x[:j]) + } + } + } else { + jx := kx + (n-1)*incX + for j := n - 1; j >= 0; j-- { + if diag == blas.NonUnit { + x[jx] /= a[j*lda+j] + } + if j > 0 { + c128.AxpyInc(-x[jx], a[j*lda:j*lda+j], x, uintptr(j), 1, uintptr(incX), 0, uintptr(kx)) + } + jx -= incX + } + } + } + return + } + + // Form x := inv(A^H)*x. + if uplo == blas.Upper { + if incX == 1 { + for j := 0; j < n; j++ { + if diag == blas.NonUnit { + x[j] /= cmplx.Conj(a[j*lda+j]) + } + xj := x[j] + for i := j + 1; i < n; i++ { + x[i] -= xj * cmplx.Conj(a[j*lda+i]) + } + } + } else { + jx := kx + for j := 0; j < n; j++ { + if diag == blas.NonUnit { + x[jx] /= cmplx.Conj(a[j*lda+j]) + } + xj := x[jx] + ix := jx + incX + for i := j + 1; i < n; i++ { + x[ix] -= xj * cmplx.Conj(a[j*lda+i]) + ix += incX + } + jx += incX + } + } + } else { + if incX == 1 { + for j := n - 1; j >= 0; j-- { + if diag == blas.NonUnit { + x[j] /= cmplx.Conj(a[j*lda+j]) + } + xj := x[j] + for i := 0; i < j; i++ { + x[i] -= xj * cmplx.Conj(a[j*lda+i]) + } + } + } else { + jx := kx + (n-1)*incX + for j := n - 1; j >= 0; j-- { + if diag == blas.NonUnit { + x[jx] /= cmplx.Conj(a[j*lda+j]) + } + xj := x[jx] + ix := kx + for i := 0; i < j; i++ { + x[ix] -= xj * cmplx.Conj(a[j*lda+i]) + ix += incX + } + jx -= incX + } + } + } +} diff --git a/vendor/github.com/gonum/blas/native/level2double.go b/vendor/gonum.org/v1/gonum/blas/gonum/level2double.go similarity index 98% rename from vendor/github.com/gonum/blas/native/level2double.go rename to vendor/gonum.org/v1/gonum/blas/gonum/level2double.go index 01c172c8..96406243 100644 --- a/vendor/github.com/gonum/blas/native/level2double.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level2double.go @@ -1,20 +1,20 @@ -// Copyright ©2014 The gonum Authors. All rights reserved. +// Copyright ©2014 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/internal/asm/f64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/internal/asm/f64" ) var _ blas.Float64Level2 = Implementation{} // Dgemv computes -// y = alpha * a * x + beta * y if tA = blas.NoTrans -// y = alpha * A^T * x + beta * y if tA = blas.Trans or blas.ConjTrans -// where A is an m×n dense matrix, x and y are vectors, and alpha is a scalar. +// y = alpha * A * x + beta * y if tA = blas.NoTrans +// y = alpha * A^T * x + beta * y if tA = blas.Trans or blas.ConjTrans +// where A is an m×n dense matrix, x and y are vectors, and alpha and beta are scalars. func (Implementation) Dgemv(tA blas.Transpose, m, n int, alpha float64, a []float64, lda int, x []float64, incX int, beta float64, y []float64, incY int) { if tA != blas.NoTrans && tA != blas.Trans && tA != blas.ConjTrans { panic(badTranspose) @@ -167,21 +167,14 @@ func (Implementation) Dger(m, n int, alpha float64, x []float64, incX int, y []f x = x[:m] y = y[:n] for i, xv := range x { - tmp := alpha * xv - if tmp != 0 { - atmp := a[i*lda : i*lda+n] - f64.AxpyUnitaryTo(atmp, tmp, y, atmp) - } + f64.AxpyUnitary(alpha*xv, y, a[i*lda:i*lda+n]) } return } ix := kx for i := 0; i < m; i++ { - tmp := alpha * x[ix] - if tmp != 0 { - f64.AxpyInc(tmp, y, a[i*lda:i*lda+n], uintptr(n), uintptr(incY), 1, uintptr(ky), 0) - } + f64.AxpyInc(alpha*x[ix], y, a[i*lda:i*lda+n], uintptr(n), uintptr(incY), 1, uintptr(ky), 0) ix += incX } } @@ -230,7 +223,7 @@ func (Implementation) Dgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float64, if (incY > 0 && (lenY-1)*incY >= len(y)) || (incY < 0 && (1-lenY)*incY >= len(y)) { panic(badY) } - if lda*(m-1)+kL+kU+1 > len(a) || lda < kL+kU+1 { + if lda*(min(m, n+kL)-1)+kL+kU+1 > len(a) || lda < kL+kU+1 { panic(badLdA) } @@ -269,7 +262,7 @@ func (Implementation) Dgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float64, if tA == blas.NoTrans { iy := ky if incX == 1 { - for i := 0; i < m; i++ { + for i := 0; i < min(m, n+kL); i++ { l := max(0, kL-i) u := min(nCol, ld+kL-i) off := max(0, i-kL) @@ -284,7 +277,7 @@ func (Implementation) Dgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float64, } return } - for i := 0; i < m; i++ { + for i := 0; i < min(m, n+kL); i++ { l := max(0, kL-i) u := min(nCol, ld+kL-i) off := max(0, i-kL) @@ -301,7 +294,7 @@ func (Implementation) Dgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float64, return } if incX == 1 { - for i := 0; i < m; i++ { + for i := 0; i < min(m, n+kL); i++ { l := max(0, kL-i) u := min(nCol, ld+kL-i) off := max(0, i-kL) @@ -316,7 +309,7 @@ func (Implementation) Dgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float64, return } ix := kx - for i := 0; i < m; i++ { + for i := 0; i < min(m, n+kL); i++ { l := max(0, kL-i) u := min(nCol, ld+kL-i) off := max(0, i-kL) @@ -1530,7 +1523,6 @@ func (Implementation) Dsbmv(ul blas.Uplo, n, k int, alpha float64, a []float64, ix += incX iy += incY } - return } // Dsyr performs the rank-one update @@ -1718,7 +1710,6 @@ func (Implementation) Dsyr2(ul blas.Uplo, n int, alpha float64, x []float64, inc ix += incX iy += incY } - return } // Dtpsv solves diff --git a/vendor/github.com/gonum/blas/native/level2single.go b/vendor/gonum.org/v1/gonum/blas/gonum/level2single.go similarity index 98% rename from vendor/github.com/gonum/blas/native/level2single.go rename to vendor/gonum.org/v1/gonum/blas/gonum/level2single.go index cf66b451..cc09015c 100644 --- a/vendor/github.com/gonum/blas/native/level2single.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level2single.go @@ -1,22 +1,22 @@ -// Code generated by "go generate github.com/gonum/blas/native"; DO NOT EDIT. +// Code generated by "go generate gonum.org/v1/gonum/blas/gonum”; DO NOT EDIT. -// Copyright ©2014 The gonum Authors. All rights reserved. +// Copyright ©2014 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/internal/asm/f32" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/internal/asm/f32" ) var _ blas.Float32Level2 = Implementation{} // Sgemv computes -// y = alpha * a * x + beta * y if tA = blas.NoTrans -// y = alpha * A^T * x + beta * y if tA = blas.Trans or blas.ConjTrans -// where A is an m×n dense matrix, x and y are vectors, and alpha is a scalar. +// y = alpha * A * x + beta * y if tA = blas.NoTrans +// y = alpha * A^T * x + beta * y if tA = blas.Trans or blas.ConjTrans +// where A is an m×n dense matrix, x and y are vectors, and alpha and beta are scalars. // // Float32 implementations are autogenerated and not directly tested. func (Implementation) Sgemv(tA blas.Transpose, m, n int, alpha float32, a []float32, lda int, x []float32, incX int, beta float32, y []float32, incY int) { @@ -173,21 +173,14 @@ func (Implementation) Sger(m, n int, alpha float32, x []float32, incX int, y []f x = x[:m] y = y[:n] for i, xv := range x { - tmp := alpha * xv - if tmp != 0 { - atmp := a[i*lda : i*lda+n] - f32.AxpyUnitaryTo(atmp, tmp, y, atmp) - } + f32.AxpyUnitary(alpha*xv, y, a[i*lda:i*lda+n]) } return } ix := kx for i := 0; i < m; i++ { - tmp := alpha * x[ix] - if tmp != 0 { - f32.AxpyInc(tmp, y, a[i*lda:i*lda+n], uintptr(n), uintptr(incY), 1, uintptr(ky), 0) - } + f32.AxpyInc(alpha*x[ix], y, a[i*lda:i*lda+n], uintptr(n), uintptr(incY), 1, uintptr(ky), 0) ix += incX } } @@ -238,7 +231,7 @@ func (Implementation) Sgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float32, if (incY > 0 && (lenY-1)*incY >= len(y)) || (incY < 0 && (1-lenY)*incY >= len(y)) { panic(badY) } - if lda*(m-1)+kL+kU+1 > len(a) || lda < kL+kU+1 { + if lda*(min(m, n+kL)-1)+kL+kU+1 > len(a) || lda < kL+kU+1 { panic(badLdA) } @@ -277,7 +270,7 @@ func (Implementation) Sgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float32, if tA == blas.NoTrans { iy := ky if incX == 1 { - for i := 0; i < m; i++ { + for i := 0; i < min(m, n+kL); i++ { l := max(0, kL-i) u := min(nCol, ld+kL-i) off := max(0, i-kL) @@ -292,7 +285,7 @@ func (Implementation) Sgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float32, } return } - for i := 0; i < m; i++ { + for i := 0; i < min(m, n+kL); i++ { l := max(0, kL-i) u := min(nCol, ld+kL-i) off := max(0, i-kL) @@ -309,7 +302,7 @@ func (Implementation) Sgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float32, return } if incX == 1 { - for i := 0; i < m; i++ { + for i := 0; i < min(m, n+kL); i++ { l := max(0, kL-i) u := min(nCol, ld+kL-i) off := max(0, i-kL) @@ -324,7 +317,7 @@ func (Implementation) Sgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float32, return } ix := kx - for i := 0; i < m; i++ { + for i := 0; i < min(m, n+kL); i++ { l := max(0, kL-i) u := min(nCol, ld+kL-i) off := max(0, i-kL) @@ -1552,7 +1545,6 @@ func (Implementation) Ssbmv(ul blas.Uplo, n, k int, alpha float32, a []float32, ix += incX iy += incY } - return } // Ssyr performs the rank-one update @@ -1744,7 +1736,6 @@ func (Implementation) Ssyr2(ul blas.Uplo, n int, alpha float32, x []float32, inc ix += incX iy += incY } - return } // Stpsv solves diff --git a/vendor/github.com/gonum/blas/native/level3double.go b/vendor/gonum.org/v1/gonum/blas/gonum/level3double.go similarity index 99% rename from vendor/github.com/gonum/blas/native/level3double.go rename to vendor/gonum.org/v1/gonum/blas/gonum/level3double.go index 3f46d775..55822463 100644 --- a/vendor/github.com/gonum/blas/native/level3double.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level3double.go @@ -1,12 +1,12 @@ -// Copyright ©2014 The gonum Authors. All rights reserved. +// Copyright ©2014 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/internal/asm/f64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/internal/asm/f64" ) var _ blas.Float64Level3 = Implementation{} diff --git a/vendor/github.com/gonum/blas/native/level3single.go b/vendor/gonum.org/v1/gonum/blas/gonum/level3single.go similarity index 98% rename from vendor/github.com/gonum/blas/native/level3single.go rename to vendor/gonum.org/v1/gonum/blas/gonum/level3single.go index 320eaad5..a7292ec0 100644 --- a/vendor/github.com/gonum/blas/native/level3single.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/level3single.go @@ -1,14 +1,14 @@ -// Code generated by "go generate github.com/gonum/blas/native"; DO NOT EDIT. +// Code generated by "go generate gonum.org/v1/gonum/blas/gonum”; DO NOT EDIT. -// Copyright ©2014 The gonum Authors. All rights reserved. +// Copyright ©2014 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/internal/asm/f32" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/internal/asm/f32" ) var _ blas.Float32Level3 = Implementation{} diff --git a/vendor/github.com/gonum/blas/native/sgemm.go b/vendor/gonum.org/v1/gonum/blas/gonum/sgemm.go similarity index 91% rename from vendor/github.com/gonum/blas/native/sgemm.go rename to vendor/gonum.org/v1/gonum/blas/gonum/sgemm.go index 1eb211fb..2e32a007 100644 --- a/vendor/github.com/gonum/blas/native/sgemm.go +++ b/vendor/gonum.org/v1/gonum/blas/gonum/sgemm.go @@ -1,17 +1,17 @@ -// Code generated by "go generate github.com/gonum/blas/native"; DO NOT EDIT. +// Code generated by "go generate gonum.org/v1/gonum/blas/gonum”; DO NOT EDIT. -// Copyright ©2014 The gonum Authors. All rights reserved. +// Copyright ©2014 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "runtime" "sync" - "github.com/gonum/blas" - "github.com/gonum/internal/asm/f32" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/internal/asm/f32" ) // Sgemm computes @@ -29,17 +29,17 @@ func (Implementation) Sgemm(tA, tB blas.Transpose, m, n, k int, alpha float32, a } aTrans := tA == blas.Trans || tA == blas.ConjTrans if aTrans { - checkMatrix32(k, m, a, lda) + checkSMatrix('a', k, m, a, lda) } else { - checkMatrix32(m, k, a, lda) + checkSMatrix('a', m, k, a, lda) } bTrans := tB == blas.Trans || tB == blas.ConjTrans if bTrans { - checkMatrix32(n, k, b, ldb) + checkSMatrix('b', n, k, b, ldb) } else { - checkMatrix32(k, n, b, ldb) + checkSMatrix('b', k, n, b, ldb) } - checkMatrix32(m, n, c, ldc) + checkSMatrix('c', m, n, c, ldc) // scale c if beta != 1 { @@ -125,7 +125,7 @@ func sgemmParallel(aTrans, bTrans bool, m, n, k int, a []float32, lda int, b []f go func() { defer wg.Done() // Make local copies of otherwise global variables to reduce shared memory. - // This has a noticable effect on benchmarks in some cases. + // This has a noticeable effect on benchmarks in some cases. alpha := alpha aTrans := aTrans bTrans := bTrans @@ -263,18 +263,3 @@ func sgemmSerialTransTrans(m, n, k int, a []float32, lda int, b []float32, ldb i func sliceView32(a []float32, lda, i, j, r, c int) []float32 { return a[i*lda+j : (i+r-1)*lda+j+c] } - -func checkMatrix32(m, n int, a []float32, lda int) { - if m < 0 { - panic("blas: rows < 0") - } - if n < 0 { - panic("blas: cols < 0") - } - if lda < n { - panic("blas: illegal stride") - } - if len(a) < (m-1)*lda+n { - panic("blas: insufficient matrix slice length") - } -} diff --git a/vendor/gonum.org/v1/gonum/floats/doc.go b/vendor/gonum.org/v1/gonum/floats/doc.go new file mode 100644 index 00000000..bfe05c19 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/floats/doc.go @@ -0,0 +1,11 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package floats provides a set of helper routines for dealing with slices +// of float64. The functions avoid allocations to allow for use within tight +// loops without garbage collection overhead. +// +// The convention used is that when a slice is being modified in place, it has +// the name dst. +package floats // import "gonum.org/v1/gonum/floats" diff --git a/vendor/github.com/gonum/floats/floats.go b/vendor/gonum.org/v1/gonum/floats/floats.go similarity index 94% rename from vendor/github.com/gonum/floats/floats.go rename to vendor/gonum.org/v1/gonum/floats/floats.go index e1807d2a..a6ecfcbb 100644 --- a/vendor/github.com/gonum/floats/floats.go +++ b/vendor/gonum.org/v1/gonum/floats/floats.go @@ -2,20 +2,15 @@ // Use of this code is governed by a BSD-style // license that can be found in the LICENSE file -// Package floats provides a set of helper routines for dealing with slices -// of float64. The functions avoid allocations to allow for use within tight -// loops without garbage collection overhead. -// -// The convention used is that when a slice is being modified in place, it has -// the name dst. package floats import ( "errors" "math" "sort" + "strconv" - "github.com/gonum/internal/asm/f64" + "gonum.org/v1/gonum/internal/asm/f64" ) // Add adds, element-wise, the elements of s and dst, and stores in dst. @@ -89,8 +84,8 @@ func (a argsort) Swap(i, j int) { a.inds[i], a.inds[j] = a.inds[j], a.inds[i] } -// Argsort sorts the elements of s while tracking their original order. -// At the conclusion of Argsort, s will contain the original elements of s +// Argsort sorts the elements of dst while tracking their original order. +// At the conclusion of Argsort, dst will contain the original elements of dst // but sorted in increasing order, and inds will contain the original position // of the elements in the slice such that dst[i] = origDst[inds[i]]. // It panics if the lengths of dst and inds do not match. @@ -342,7 +337,6 @@ func EqualLengths(slices ...[]float64) bool { // all of the found elements will be returned along with an error. // At the return of the function, the input inds will be in an undetermined state. func Find(inds []int, f func(float64) bool, s []float64, k int) ([]int, error) { - // inds is also returned to allow for calling with nil // Reslice inds to have zero length @@ -495,6 +489,29 @@ func MulTo(dst, s, t []float64) []float64 { return dst } +const ( + nanBits = 0x7ff8000000000000 + nanMask = 0xfff8000000000000 +) + +// NaNWith returns an IEEE 754 "quiet not-a-number" value with the +// payload specified in the low 51 bits of payload. +// The NaN returned by math.NaN has a bit pattern equal to NaNWith(1). +func NaNWith(payload uint64) float64 { + return math.Float64frombits(nanBits | (payload &^ nanMask)) +} + +// NaNPayload returns the lowest 51 bits payload of an IEEE 754 "quiet +// not-a-number". For values of f other than quiet-NaN, NaNPayload +// returns zero and false. +func NaNPayload(f float64) (payload uint64, ok bool) { + b := math.Float64bits(f) + if b&nanBits != nanBits { + return 0, false + } + return b &^ nanMask, true +} + // Nearest returns the index of the element in s // whose value is nearest to v. If several such // elements exist, the lowest index is returned. @@ -567,6 +584,19 @@ func Norm(s []float64, L float64) float64 { return math.Pow(norm, 1/L) } +// ParseWithNA converts the string s to a float64 in v. +// If s equals missing, w is returned as 0, otherwise 1. +func ParseWithNA(s, missing string) (v, w float64, err error) { + if s == missing { + return 0, 0, nil + } + v, err = strconv.ParseFloat(s, 64) + if err == nil { + w = 1 + } + return v, w, err +} + // Prod returns the product of the elements of the slice. // Returns 1 if len(s) = 0. func Prod(s []float64) float64 { diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyinc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyinc_amd64.s new file mode 100644 index 00000000..2ae34daa --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyinc_amd64.s @@ -0,0 +1,134 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +// MOVDDUP X2, X3 +#define MOVDDUP_X2_X3 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xDA +// MOVDDUP X4, X5 +#define MOVDDUP_X4_X5 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xEC +// MOVDDUP X6, X7 +#define MOVDDUP_X6_X7 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xFE +// MOVDDUP X8, X9 +#define MOVDDUP_X8_X9 BYTE $0xF2; BYTE $0x45; BYTE $0x0F; BYTE $0x12; BYTE $0xC8 + +// ADDSUBPD X2, X3 +#define ADDSUBPD_X2_X3 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xDA +// ADDSUBPD X4, X5 +#define ADDSUBPD_X4_X5 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xEC +// ADDSUBPD X6, X7 +#define ADDSUBPD_X6_X7 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xFE +// ADDSUBPD X8, X9 +#define ADDSUBPD_X8_X9 BYTE $0x66; BYTE $0x45; BYTE $0x0F; BYTE $0xD0; BYTE $0xC8 + +// func AxpyInc(alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) +TEXT ·AxpyInc(SB), NOSPLIT, $0 + MOVQ x_base+16(FP), SI // SI = &x + MOVQ y_base+40(FP), DI // DI = &y + MOVQ n+64(FP), CX // CX = n + CMPQ CX, $0 // if n==0 { return } + JE axpyi_end + MOVQ ix+88(FP), R8 // R8 = ix // Load the first index + SHLQ $4, R8 // R8 *= sizeof(complex128) + MOVQ iy+96(FP), R9 // R9 = iy + SHLQ $4, R9 // R9 *= sizeof(complex128) + LEAQ (SI)(R8*1), SI // SI = &(x[ix]) + LEAQ (DI)(R9*1), DI // DI = &(y[iy]) + MOVQ DI, DX // DX = DI // Separate Read/Write pointers + MOVQ incX+72(FP), R8 // R8 = incX + SHLQ $4, R8 // R8 *= sizeof(complex128) + MOVQ incY+80(FP), R9 // R9 = iy + SHLQ $4, R9 // R9 *= sizeof(complex128) + MOVUPS alpha+0(FP), X0 // X0 = { imag(a), real(a) } + MOVAPS X0, X1 + SHUFPD $0x1, X1, X1 // X1 = { real(a), imag(a) } + MOVAPS X0, X10 // Copy X0 and X1 for pipelining + MOVAPS X1, X11 + MOVQ CX, BX + ANDQ $3, CX // CX = n % 4 + SHRQ $2, BX // BX = floor( n / 4 ) + JZ axpyi_tail // if BX == 0 { goto axpyi_tail } + +axpyi_loop: // do { + MOVUPS (SI), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVUPS (SI)(R8*1), X4 + LEAQ (SI)(R8*2), SI // SI = &(SI[incX*2]) + MOVUPS (SI), X6 + MOVUPS (SI)(R8*1), X8 + + // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_X2_X3 + MOVDDUP_X4_X5 + MOVDDUP_X6_X7 + MOVDDUP_X8_X9 + + // X_i = { imag(x[i]), imag(x[i]) } + SHUFPD $0x3, X2, X2 + SHUFPD $0x3, X4, X4 + SHUFPD $0x3, X6, X6 + SHUFPD $0x3, X8, X8 + + // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + MULPD X1, X2 + MULPD X0, X3 + MULPD X11, X4 + MULPD X10, X5 + MULPD X1, X6 + MULPD X0, X7 + MULPD X11, X8 + MULPD X10, X9 + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDSUBPD_X4_X5 + ADDSUBPD_X6_X7 + ADDSUBPD_X8_X9 + + // X_(i+1) = { imag(result[i]) + imag(y[i]), real(result[i]) + real(y[i]) } + ADDPD (DX), X3 + ADDPD (DX)(R9*1), X5 + LEAQ (DX)(R9*2), DX // DX = &(DX[incY*2]) + ADDPD (DX), X7 + ADDPD (DX)(R9*1), X9 + MOVUPS X3, (DI) // dst[i] = X_(i+1) + MOVUPS X5, (DI)(R9*1) + LEAQ (DI)(R9*2), DI + MOVUPS X7, (DI) + MOVUPS X9, (DI)(R9*1) + LEAQ (SI)(R8*2), SI // SI = &(SI[incX*2]) + LEAQ (DX)(R9*2), DX // DX = &(DX[incY*2]) + LEAQ (DI)(R9*2), DI // DI = &(DI[incY*2]) + DECQ BX + JNZ axpyi_loop // } while --BX > 0 + CMPQ CX, $0 // if CX == 0 { return } + JE axpyi_end + +axpyi_tail: // do { + MOVUPS (SI), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVDDUP_X2_X3 // X_(i+1) = { real(x[i], real(x[i]) } + SHUFPD $0x3, X2, X2 // X_i = { imag(x[i]), imag(x[i]) } + MULPD X1, X2 // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + MULPD X0, X3 // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + + // X_(i+1) = { imag(result[i]) + imag(y[i]), real(result[i]) + real(y[i]) } + ADDPD (DI), X3 + MOVUPS X3, (DI) // y[i] = X_i + ADDQ R8, SI // SI = &(SI[incX]) + ADDQ R9, DI // DI = &(DI[incY]) + LOOP axpyi_tail // } while --CX > 0 + +axpyi_end: + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyincto_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyincto_amd64.s new file mode 100644 index 00000000..127e4891 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyincto_amd64.s @@ -0,0 +1,141 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +// MOVDDUP X2, X3 +#define MOVDDUP_X2_X3 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xDA +// MOVDDUP X4, X5 +#define MOVDDUP_X4_X5 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xEC +// MOVDDUP X6, X7 +#define MOVDDUP_X6_X7 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xFE +// MOVDDUP X8, X9 +#define MOVDDUP_X8_X9 BYTE $0xF2; BYTE $0x45; BYTE $0x0F; BYTE $0x12; BYTE $0xC8 + +// ADDSUBPD X2, X3 +#define ADDSUBPD_X2_X3 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xDA +// ADDSUBPD X4, X5 +#define ADDSUBPD_X4_X5 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xEC +// ADDSUBPD X6, X7 +#define ADDSUBPD_X6_X7 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xFE +// ADDSUBPD X8, X9 +#define ADDSUBPD_X8_X9 BYTE $0x66; BYTE $0x45; BYTE $0x0F; BYTE $0xD0; BYTE $0xC8 + +// func AxpyIncTo(dst []complex128, incDst, idst uintptr, alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) +TEXT ·AxpyIncTo(SB), NOSPLIT, $0 + MOVQ dst_base+0(FP), DI // DI = &dst + MOVQ x_base+56(FP), SI // SI = &x + MOVQ y_base+80(FP), DX // DX = &y + MOVQ n+104(FP), CX // CX = n + CMPQ CX, $0 // if n==0 { return } + JE axpyi_end + MOVQ ix+128(FP), R8 // R8 = ix // Load the first index + SHLQ $4, R8 // R8 *= sizeof(complex128) + MOVQ iy+136(FP), R9 // R9 = iy + SHLQ $4, R9 // R9 *= sizeof(complex128) + MOVQ idst+32(FP), R10 // R10 = idst + SHLQ $4, R10 // R10 *= sizeof(complex128) + LEAQ (SI)(R8*1), SI // SI = &(x[ix]) + LEAQ (DX)(R9*1), DX // DX = &(y[iy]) + LEAQ (DI)(R10*1), DI // DI = &(dst[idst]) + MOVQ incX+112(FP), R8 // R8 = incX + SHLQ $4, R8 // R8 *= sizeof(complex128) + MOVQ incY+120(FP), R9 // R9 = incY + SHLQ $4, R9 // R9 *= sizeof(complex128) + MOVQ incDst+24(FP), R10 // R10 = incDst + SHLQ $4, R10 // R10 *= sizeof(complex128) + MOVUPS alpha+40(FP), X0 // X0 = { imag(a), real(a) } + MOVAPS X0, X1 + SHUFPD $0x1, X1, X1 // X1 = { real(a), imag(a) } + MOVAPS X0, X10 // Copy X0 and X1 for pipelining + MOVAPS X1, X11 + MOVQ CX, BX + ANDQ $3, CX // CX = n % 4 + SHRQ $2, BX // BX = floor( n / 4 ) + JZ axpyi_tail // if BX == 0 { goto axpyi_tail } + +axpyi_loop: // do { + MOVUPS (SI), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVUPS (SI)(R8*1), X4 + LEAQ (SI)(R8*2), SI // SI = &(SI[incX*2]) + + MOVUPS (SI), X6 + MOVUPS (SI)(R8*1), X8 + + // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_X2_X3 + MOVDDUP_X4_X5 + MOVDDUP_X6_X7 + MOVDDUP_X8_X9 + + // X_i = { imag(x[i]), imag(x[i]) } + SHUFPD $0x3, X2, X2 + SHUFPD $0x3, X4, X4 + SHUFPD $0x3, X6, X6 + SHUFPD $0x3, X8, X8 + + // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + MULPD X1, X2 + MULPD X0, X3 + MULPD X11, X4 + MULPD X10, X5 + MULPD X1, X6 + MULPD X0, X7 + MULPD X11, X8 + MULPD X10, X9 + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDSUBPD_X4_X5 + ADDSUBPD_X6_X7 + ADDSUBPD_X8_X9 + + // X_(i+1) = { imag(result[i]) + imag(y[i]), real(result[i]) + real(y[i]) } + ADDPD (DX), X3 + ADDPD (DX)(R9*1), X5 + LEAQ (DX)(R9*2), DX // DX = &(DX[incY*2]) + ADDPD (DX), X7 + ADDPD (DX)(R9*1), X9 + MOVUPS X3, (DI) // dst[i] = X_(i+1) + MOVUPS X5, (DI)(R10*1) + LEAQ (DI)(R10*2), DI + MOVUPS X7, (DI) + MOVUPS X9, (DI)(R10*1) + LEAQ (SI)(R8*2), SI // SI = &(SI[incX*2]) + LEAQ (DX)(R9*2), DX // DX = &(DX[incY*2]) + LEAQ (DI)(R10*2), DI // DI = &(DI[incDst*2]) + DECQ BX + JNZ axpyi_loop // } while --BX > 0 + CMPQ CX, $0 // if CX == 0 { return } + JE axpyi_end + +axpyi_tail: // do { + MOVUPS (SI), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVDDUP_X2_X3 // X_(i+1) = { real(x[i], real(x[i]) } + SHUFPD $0x3, X2, X2 // X_i = { imag(x[i]), imag(x[i]) } + MULPD X1, X2 // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + MULPD X0, X3 // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + + // X_(i+1) = { imag(result[i]) + imag(y[i]), real(result[i]) + real(y[i]) } + ADDPD (DX), X3 + MOVUPS X3, (DI) // y[i] X_(i+1) + ADDQ R8, SI // SI += incX + ADDQ R9, DX // DX += incY + ADDQ R10, DI // DI += incDst + LOOP axpyi_tail // } while --CX > 0 + +axpyi_end: + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyunitary_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyunitary_amd64.s new file mode 100644 index 00000000..2a6c80e0 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyunitary_amd64.s @@ -0,0 +1,122 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +// MOVDDUP X2, X3 +#define MOVDDUP_X2_X3 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xDA +// MOVDDUP X4, X5 +#define MOVDDUP_X4_X5 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xEC +// MOVDDUP X6, X7 +#define MOVDDUP_X6_X7 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xFE +// MOVDDUP X8, X9 +#define MOVDDUP_X8_X9 BYTE $0xF2; BYTE $0x45; BYTE $0x0F; BYTE $0x12; BYTE $0xC8 + +// ADDSUBPD X2, X3 +#define ADDSUBPD_X2_X3 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xDA +// ADDSUBPD X4, X5 +#define ADDSUBPD_X4_X5 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xEC +// ADDSUBPD X6, X7 +#define ADDSUBPD_X6_X7 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xFE +// ADDSUBPD X8, X9 +#define ADDSUBPD_X8_X9 BYTE $0x66; BYTE $0x45; BYTE $0x0F; BYTE $0xD0; BYTE $0xC8 + +// func AxpyUnitary(alpha complex128, x, y []complex128) +TEXT ·AxpyUnitary(SB), NOSPLIT, $0 + MOVQ x_base+16(FP), SI // SI = &x + MOVQ y_base+40(FP), DI // DI = &y + MOVQ x_len+24(FP), CX // CX = min( len(x), len(y) ) + CMPQ y_len+48(FP), CX + CMOVQLE y_len+48(FP), CX + CMPQ CX, $0 // if CX == 0 { return } + JE caxy_end + PXOR X0, X0 // Clear work registers and cache-align loop + PXOR X1, X1 + MOVUPS alpha+0(FP), X0 // X0 = { imag(a), real(a) } + MOVAPS X0, X1 + SHUFPD $0x1, X1, X1 // X1 = { real(a), imag(a) } + XORQ AX, AX // i = 0 + MOVAPS X0, X10 // Copy X0 and X1 for pipelining + MOVAPS X1, X11 + MOVQ CX, BX + ANDQ $3, CX // CX = n % 4 + SHRQ $2, BX // BX = floor( n / 4 ) + JZ caxy_tail // if BX == 0 { goto caxy_tail } + +caxy_loop: // do { + MOVUPS (SI)(AX*8), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVUPS 16(SI)(AX*8), X4 + MOVUPS 32(SI)(AX*8), X6 + MOVUPS 48(SI)(AX*8), X8 + + // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_X2_X3 + MOVDDUP_X4_X5 + MOVDDUP_X6_X7 + MOVDDUP_X8_X9 + + // X_i = { imag(x[i]), imag(x[i]) } + SHUFPD $0x3, X2, X2 + SHUFPD $0x3, X4, X4 + SHUFPD $0x3, X6, X6 + SHUFPD $0x3, X8, X8 + + // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + MULPD X1, X2 + MULPD X0, X3 + MULPD X11, X4 + MULPD X10, X5 + MULPD X1, X6 + MULPD X0, X7 + MULPD X11, X8 + MULPD X10, X9 + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDSUBPD_X4_X5 + ADDSUBPD_X6_X7 + ADDSUBPD_X8_X9 + + // X_(i+1) = { imag(result[i]) + imag(y[i]), real(result[i]) + real(y[i]) } + ADDPD (DI)(AX*8), X3 + ADDPD 16(DI)(AX*8), X5 + ADDPD 32(DI)(AX*8), X7 + ADDPD 48(DI)(AX*8), X9 + MOVUPS X3, (DI)(AX*8) // y[i] = X_(i+1) + MOVUPS X5, 16(DI)(AX*8) + MOVUPS X7, 32(DI)(AX*8) + MOVUPS X9, 48(DI)(AX*8) + ADDQ $8, AX // i += 8 + DECQ BX + JNZ caxy_loop // } while --BX > 0 + CMPQ CX, $0 // if CX == 0 { return } + JE caxy_end + +caxy_tail: // do { + MOVUPS (SI)(AX*8), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVDDUP_X2_X3 // X_(i+1) = { real(x[i], real(x[i]) } + SHUFPD $0x3, X2, X2 // X_i = { imag(x[i]), imag(x[i]) } + MULPD X1, X2 // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + MULPD X0, X3 // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + + // X_(i+1) = { imag(result[i]) + imag(y[i]), real(result[i]) + real(y[i]) } + ADDPD (DI)(AX*8), X3 + MOVUPS X3, (DI)(AX*8) // y[i] = X_(i+1) + ADDQ $2, AX // i += 2 + LOOP caxy_tail // } while --CX > 0 + +caxy_end: + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyunitaryto_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyunitaryto_amd64.s new file mode 100644 index 00000000..db5b3355 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/axpyunitaryto_amd64.s @@ -0,0 +1,123 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +// MOVDDUP X2, X3 +#define MOVDDUP_X2_X3 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xDA +// MOVDDUP X4, X5 +#define MOVDDUP_X4_X5 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xEC +// MOVDDUP X6, X7 +#define MOVDDUP_X6_X7 BYTE $0xF2; BYTE $0x0F; BYTE $0x12; BYTE $0xFE +// MOVDDUP X8, X9 +#define MOVDDUP_X8_X9 BYTE $0xF2; BYTE $0x45; BYTE $0x0F; BYTE $0x12; BYTE $0xC8 + +// ADDSUBPD X2, X3 +#define ADDSUBPD_X2_X3 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xDA +// ADDSUBPD X4, X5 +#define ADDSUBPD_X4_X5 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xEC +// ADDSUBPD X6, X7 +#define ADDSUBPD_X6_X7 BYTE $0x66; BYTE $0x0F; BYTE $0xD0; BYTE $0xFE +// ADDSUBPD X8, X9 +#define ADDSUBPD_X8_X9 BYTE $0x66; BYTE $0x45; BYTE $0x0F; BYTE $0xD0; BYTE $0xC8 + +// func AxpyUnitaryTo(dst []complex128, alpha complex64, x, y []complex128) +TEXT ·AxpyUnitaryTo(SB), NOSPLIT, $0 + MOVQ dst_base+0(FP), DI // DI = &dst + MOVQ x_base+40(FP), SI // SI = &x + MOVQ y_base+64(FP), DX // DX = &y + MOVQ x_len+48(FP), CX // CX = min( len(x), len(y), len(dst) ) + CMPQ y_len+72(FP), CX + CMOVQLE y_len+72(FP), CX + CMPQ dst_len+8(FP), CX + CMOVQLE dst_len+8(FP), CX + CMPQ CX, $0 // if CX == 0 { return } + JE caxy_end + MOVUPS alpha+24(FP), X0 // X0 = { imag(a), real(a) } + MOVAPS X0, X1 + SHUFPD $0x1, X1, X1 // X1 = { real(a), imag(a) } + XORQ AX, AX // i = 0 + MOVAPS X0, X10 // Copy X0 and X1 for pipelining + MOVAPS X1, X11 + MOVQ CX, BX + ANDQ $3, CX // CX = n % 4 + SHRQ $2, BX // BX = floor( n / 4 ) + JZ caxy_tail // if BX == 0 { goto caxy_tail } + +caxy_loop: // do { + MOVUPS (SI)(AX*8), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVUPS 16(SI)(AX*8), X4 + MOVUPS 32(SI)(AX*8), X6 + MOVUPS 48(SI)(AX*8), X8 + + // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_X2_X3 // Load and duplicate imag elements (xi, xi) + MOVDDUP_X4_X5 + MOVDDUP_X6_X7 + MOVDDUP_X8_X9 + + // X_i = { imag(x[i]), imag(x[i]) } + SHUFPD $0x3, X2, X2 // duplicate real elements (xr, xr) + SHUFPD $0x3, X4, X4 + SHUFPD $0x3, X6, X6 + SHUFPD $0x3, X8, X8 + + // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + MULPD X1, X2 + MULPD X0, X3 + MULPD X11, X4 + MULPD X10, X5 + MULPD X1, X6 + MULPD X0, X7 + MULPD X11, X8 + MULPD X10, X9 + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDSUBPD_X4_X5 + ADDSUBPD_X6_X7 + ADDSUBPD_X8_X9 + + // X_(i+1) = { imag(result[i]) + imag(y[i]), real(result[i]) + real(y[i]) } + ADDPD (DX)(AX*8), X3 + ADDPD 16(DX)(AX*8), X5 + ADDPD 32(DX)(AX*8), X7 + ADDPD 48(DX)(AX*8), X9 + MOVUPS X3, (DI)(AX*8) // y[i] = X_(i+1) + MOVUPS X5, 16(DI)(AX*8) + MOVUPS X7, 32(DI)(AX*8) + MOVUPS X9, 48(DI)(AX*8) + ADDQ $8, AX // i += 8 + DECQ BX + JNZ caxy_loop // } while --BX > 0 + CMPQ CX, $0 // if CX == 0 { return } + JE caxy_end + +caxy_tail: // Same calculation, but read in values to avoid trampling memory + MOVUPS (SI)(AX*8), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVDDUP_X2_X3 // X_(i+1) = { real(x[i], real(x[i]) } + SHUFPD $0x3, X2, X2 // X_i = { imag(x[i]), imag(x[i]) } + MULPD X1, X2 // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + MULPD X0, X3 // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + + // X_(i+1) = { imag(result[i]) + imag(y[i]), real(result[i]) + real(y[i]) } + ADDPD (DX)(AX*8), X3 + MOVUPS X3, (DI)(AX*8) // y[i] = X_(i+1) + ADDQ $2, AX // i += 2 + LOOP caxy_tail // } while --CX > 0 + +caxy_end: + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/doc.go b/vendor/gonum.org/v1/gonum/internal/asm/c128/doc.go new file mode 100644 index 00000000..8802ff13 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/doc.go @@ -0,0 +1,6 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package c128 provides complex128 vector primitives. +package c128 // import "gonum.org/v1/gonum/internal/asm/c128" diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/dotcinc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/dotcinc_amd64.s new file mode 100644 index 00000000..ce664235 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/dotcinc_amd64.s @@ -0,0 +1,153 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define MOVDDUP_XPTR__X3 LONG $0x1E120FF2 // MOVDDUP (SI), X3 +#define MOVDDUP_XPTR_INCX__X5 LONG $0x120F42F2; WORD $0x062C // MOVDDUP (SI)(R8*1), X5 +#define MOVDDUP_XPTR_INCX_2__X7 LONG $0x120F42F2; WORD $0x463C // MOVDDUP (SI)(R8*2), X7 +#define MOVDDUP_XPTR_INCx3X__X9 LONG $0x120F46F2; WORD $0x0E0C // MOVDDUP (SI)(R9*1), X9 + +#define MOVDDUP_8_XPTR__X2 LONG $0x56120FF2; BYTE $0x08 // MOVDDUP 8(SI), X2 +#define MOVDDUP_8_XPTR_INCX__X4 LONG $0x120F42F2; WORD $0x0664; BYTE $0x08 // MOVDDUP 8(SI)(R8*1), X4 +#define MOVDDUP_8_XPTR_INCX_2__X6 LONG $0x120F42F2; WORD $0x4674; BYTE $0x08 // MOVDDUP 8(SI)(R8*2), X6 +#define MOVDDUP_8_XPTR_INCx3X__X8 LONG $0x120F46F2; WORD $0x0E44; BYTE $0x08 // MOVDDUP 8(SI)(R9*1), X8 + +#define ADDSUBPD_X2_X3 LONG $0xDAD00F66 // ADDSUBPD X2, X3 +#define ADDSUBPD_X4_X5 LONG $0xECD00F66 // ADDSUBPD X4, X5 +#define ADDSUBPD_X6_X7 LONG $0xFED00F66 // ADDSUBPD X6, X7 +#define ADDSUBPD_X8_X9 LONG $0xD00F4566; BYTE $0xC8 // ADDSUBPD X8, X9 + +#define X_PTR SI +#define Y_PTR DI +#define LEN CX +#define TAIL BX +#define SUM X0 +#define P_SUM X1 +#define INC_X R8 +#define INCx3_X R9 +#define INC_Y R10 +#define INCx3_Y R11 +#define NEG1 X15 +#define P_NEG1 X14 + +// func DotcInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) +TEXT ·DotcInc(SB), NOSPLIT, $0 + MOVQ x_base+0(FP), X_PTR // X_PTR = &x + MOVQ y_base+24(FP), Y_PTR // Y_PTR = &y + MOVQ n+48(FP), LEN // LEN = n + PXOR SUM, SUM // SUM = 0 + CMPQ LEN, $0 // if LEN == 0 { return } + JE dot_end + PXOR P_SUM, P_SUM // P_SUM = 0 + MOVQ ix+72(FP), INC_X // INC_X = ix * sizeof(complex128) + SHLQ $4, INC_X + MOVQ iy+80(FP), INC_Y // INC_Y = iy * sizeof(complex128) + SHLQ $4, INC_Y + LEAQ (X_PTR)(INC_X*1), X_PTR // X_PTR = &(X_PTR[ix]) + LEAQ (Y_PTR)(INC_Y*1), Y_PTR // Y_PTR = &(Y_PTR[iy]) + MOVQ incX+56(FP), INC_X // INC_X = incX + SHLQ $4, INC_X // INC_X *= sizeof(complex128) + MOVQ incY+64(FP), INC_Y // INC_Y = incY + SHLQ $4, INC_Y // INC_Y *= sizeof(complex128) + MOVSD $(-1.0), NEG1 + SHUFPD $0, NEG1, NEG1 // { -1, -1 } + MOVQ LEN, TAIL + ANDQ $3, TAIL // TAIL = n % 4 + SHRQ $2, LEN // LEN = floor( n / 4 ) + JZ dot_tail // if n <= 4 { goto dot_tail } + MOVAPS NEG1, P_NEG1 // Copy NEG1 to P_NEG1 for pipelining + LEAQ (INC_X)(INC_X*2), INCx3_X // INCx3_X = 3 * incX * sizeof(complex128) + LEAQ (INC_Y)(INC_Y*2), INCx3_Y // INCx3_Y = 3 * incY * sizeof(complex128) + +dot_loop: // do { + MOVDDUP_XPTR__X3 // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_XPTR_INCX__X5 + MOVDDUP_XPTR_INCX_2__X7 + MOVDDUP_XPTR_INCx3X__X9 + + MOVDDUP_8_XPTR__X2 // X_i = { imag(x[i]), imag(x[i]) } + MOVDDUP_8_XPTR_INCX__X4 + MOVDDUP_8_XPTR_INCX_2__X6 + MOVDDUP_8_XPTR_INCx3X__X8 + + // X_i = { -imag(x[i]), -imag(x[i]) } + MULPD NEG1, X2 + MULPD P_NEG1, X4 + MULPD NEG1, X6 + MULPD P_NEG1, X8 + + // X_j = { imag(y[i]), real(y[i]) } + MOVUPS (Y_PTR), X10 + MOVUPS (Y_PTR)(INC_Y*1), X11 + MOVUPS (Y_PTR)(INC_Y*2), X12 + MOVUPS (Y_PTR)(INCx3_Y*1), X13 + + // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + MULPD X10, X3 + MULPD X11, X5 + MULPD X12, X7 + MULPD X13, X9 + + // X_j = { real(y[i]), imag(y[i]) } + SHUFPD $0x1, X10, X10 + SHUFPD $0x1, X11, X11 + SHUFPD $0x1, X12, X12 + SHUFPD $0x1, X13, X13 + + // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + MULPD X10, X2 + MULPD X11, X4 + MULPD X12, X6 + MULPD X13, X8 + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDSUBPD_X4_X5 + ADDSUBPD_X6_X7 + ADDSUBPD_X8_X9 + + // psum += result[i] + ADDPD X3, SUM + ADDPD X5, P_SUM + ADDPD X7, SUM + ADDPD X9, P_SUM + + LEAQ (X_PTR)(INC_X*4), X_PTR // X_PTR = &(X_PTR[incX*4]) + LEAQ (Y_PTR)(INC_Y*4), Y_PTR // Y_PTR = &(Y_PTR[incY*4]) + + DECQ LEN + JNZ dot_loop // } while --LEN > 0 + ADDPD P_SUM, SUM // sum += psum + CMPQ TAIL, $0 // if TAIL == 0 { return } + JE dot_end + +dot_tail: // do { + MOVDDUP_XPTR__X3 // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_8_XPTR__X2 // X_i = { imag(x[i]), imag(x[i]) } + MULPD NEG1, X2 // X_i = { -imag(x[i]) , -imag(x[i]) } + MOVUPS (Y_PTR), X10 // X_j = { imag(y[i]) , real(y[i]) } + MULPD X10, X3 // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + SHUFPD $0x1, X10, X10 // X_j = { real(y[i]) , imag(y[i]) } + MULPD X10, X2 // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDPD X3, SUM // sum += result[i] + ADDQ INC_X, X_PTR // X_PTR += incX + ADDQ INC_Y, Y_PTR // Y_PTR += incY + DECQ TAIL + JNZ dot_tail // } while --TAIL > 0 + +dot_end: + MOVUPS SUM, sum+88(FP) + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/dotcunitary_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/dotcunitary_amd64.s new file mode 100644 index 00000000..34e78b85 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/dotcunitary_amd64.s @@ -0,0 +1,143 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define MOVDDUP_XPTR_IDX_8__X3 LONG $0x1C120FF2; BYTE $0xC6 // MOVDDUP (SI)(AX*8), X3 +#define MOVDDUP_16_XPTR_IDX_8__X5 LONG $0x6C120FF2; WORD $0x10C6 // MOVDDUP 16(SI)(AX*8), X5 +#define MOVDDUP_32_XPTR_IDX_8__X7 LONG $0x7C120FF2; WORD $0x20C6 // MOVDDUP 32(SI)(AX*8), X7 +#define MOVDDUP_48_XPTR_IDX_8__X9 LONG $0x120F44F2; WORD $0xC64C; BYTE $0x30 // MOVDDUP 48(SI)(AX*8), X9 + +#define MOVDDUP_XPTR_IIDX_8__X2 LONG $0x14120FF2; BYTE $0xD6 // MOVDDUP (SI)(DX*8), X2 +#define MOVDDUP_16_XPTR_IIDX_8__X4 LONG $0x64120FF2; WORD $0x10D6 // MOVDDUP 16(SI)(DX*8), X4 +#define MOVDDUP_32_XPTR_IIDX_8__X6 LONG $0x74120FF2; WORD $0x20D6 // MOVDDUP 32(SI)(DX*8), X6 +#define MOVDDUP_48_XPTR_IIDX_8__X8 LONG $0x120F44F2; WORD $0xD644; BYTE $0x30 // MOVDDUP 48(SI)(DX*8), X8 + +#define ADDSUBPD_X2_X3 LONG $0xDAD00F66 // ADDSUBPD X2, X3 +#define ADDSUBPD_X4_X5 LONG $0xECD00F66 // ADDSUBPD X4, X5 +#define ADDSUBPD_X6_X7 LONG $0xFED00F66 // ADDSUBPD X6, X7 +#define ADDSUBPD_X8_X9 LONG $0xD00F4566; BYTE $0xC8 // ADDSUBPD X8, X9 + +#define X_PTR SI +#define Y_PTR DI +#define LEN CX +#define TAIL BX +#define SUM X0 +#define P_SUM X1 +#define IDX AX +#define I_IDX DX +#define NEG1 X15 +#define P_NEG1 X14 + +// func DotcUnitary(x, y []complex128) (sum complex128) +TEXT ·DotcUnitary(SB), NOSPLIT, $0 + MOVQ x_base+0(FP), X_PTR // X_PTR = &x + MOVQ y_base+24(FP), Y_PTR // Y_PTR = &y + MOVQ x_len+8(FP), LEN // LEN = min( len(x), len(y) ) + CMPQ y_len+32(FP), LEN + CMOVQLE y_len+32(FP), LEN + PXOR SUM, SUM // sum = 0 + CMPQ LEN, $0 // if LEN == 0 { return } + JE dot_end + XORPS P_SUM, P_SUM // psum = 0 + MOVSD $(-1.0), NEG1 + SHUFPD $0, NEG1, NEG1 // { -1, -1 } + XORQ IDX, IDX // i := 0 + MOVQ $1, I_IDX // j := 1 + MOVQ LEN, TAIL + ANDQ $3, TAIL // TAIL = floor( TAIL / 4 ) + SHRQ $2, LEN // LEN = TAIL % 4 + JZ dot_tail // if LEN == 0 { goto dot_tail } + + MOVAPS NEG1, P_NEG1 // Copy NEG1 to P_NEG1 for pipelining + +dot_loop: // do { + MOVDDUP_XPTR_IDX_8__X3 // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_16_XPTR_IDX_8__X5 + MOVDDUP_32_XPTR_IDX_8__X7 + MOVDDUP_48_XPTR_IDX_8__X9 + + MOVDDUP_XPTR_IIDX_8__X2 // X_i = { imag(x[i]), imag(x[i]) } + MOVDDUP_16_XPTR_IIDX_8__X4 + MOVDDUP_32_XPTR_IIDX_8__X6 + MOVDDUP_48_XPTR_IIDX_8__X8 + + // X_i = { -imag(x[i]), -imag(x[i]) } + MULPD NEG1, X2 + MULPD P_NEG1, X4 + MULPD NEG1, X6 + MULPD P_NEG1, X8 + + // X_j = { imag(y[i]), real(y[i]) } + MOVUPS (Y_PTR)(IDX*8), X10 + MOVUPS 16(Y_PTR)(IDX*8), X11 + MOVUPS 32(Y_PTR)(IDX*8), X12 + MOVUPS 48(Y_PTR)(IDX*8), X13 + + // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + MULPD X10, X3 + MULPD X11, X5 + MULPD X12, X7 + MULPD X13, X9 + + // X_j = { real(y[i]), imag(y[i]) } + SHUFPD $0x1, X10, X10 + SHUFPD $0x1, X11, X11 + SHUFPD $0x1, X12, X12 + SHUFPD $0x1, X13, X13 + + // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + MULPD X10, X2 + MULPD X11, X4 + MULPD X12, X6 + MULPD X13, X8 + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDSUBPD_X4_X5 + ADDSUBPD_X6_X7 + ADDSUBPD_X8_X9 + + // psum += result[i] + ADDPD X3, SUM + ADDPD X5, P_SUM + ADDPD X7, SUM + ADDPD X9, P_SUM + + ADDQ $8, IDX // IDX += 8 + ADDQ $8, I_IDX // I_IDX += 8 + DECQ LEN + JNZ dot_loop // } while --LEN > 0 + ADDPD P_SUM, SUM // sum += psum + CMPQ TAIL, $0 // if TAIL == 0 { return } + JE dot_end + +dot_tail: // do { + MOVDDUP_XPTR_IDX_8__X3 // X_(i+1) = { real(x[i]) , real(x[i]) } + MOVDDUP_XPTR_IIDX_8__X2 // X_i = { imag(x[i]) , imag(x[i]) } + MULPD NEG1, X2 // X_i = { -imag(x[i]) , -imag(x[i]) } + MOVUPS (Y_PTR)(IDX*8), X10 // X_j = { imag(y[i]) , real(y[i]) } + MULPD X10, X3 // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + SHUFPD $0x1, X10, X10 // X_j = { real(y[i]) , imag(y[i]) } + MULPD X10, X2 // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDPD X3, SUM // SUM += result[i] + ADDQ $2, IDX // IDX += 2 + ADDQ $2, I_IDX // I_IDX += 2 + DECQ TAIL + JNZ dot_tail // } while --TAIL > 0 + +dot_end: + MOVUPS SUM, sum+48(FP) + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/dotuinc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/dotuinc_amd64.s new file mode 100644 index 00000000..59eccf2b --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/dotuinc_amd64.s @@ -0,0 +1,141 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define MOVDDUP_XPTR__X3 LONG $0x1E120FF2 // MOVDDUP (SI), X3 +#define MOVDDUP_XPTR_INCX__X5 LONG $0x120F42F2; WORD $0x062C // MOVDDUP (SI)(R8*1), X5 +#define MOVDDUP_XPTR_INCX_2__X7 LONG $0x120F42F2; WORD $0x463C // MOVDDUP (SI)(R8*2), X7 +#define MOVDDUP_XPTR_INCx3X__X9 LONG $0x120F46F2; WORD $0x0E0C // MOVDDUP (SI)(R9*1), X9 + +#define MOVDDUP_8_XPTR__X2 LONG $0x56120FF2; BYTE $0x08 // MOVDDUP 8(SI), X2 +#define MOVDDUP_8_XPTR_INCX__X4 LONG $0x120F42F2; WORD $0x0664; BYTE $0x08 // MOVDDUP 8(SI)(R8*1), X4 +#define MOVDDUP_8_XPTR_INCX_2__X6 LONG $0x120F42F2; WORD $0x4674; BYTE $0x08 // MOVDDUP 8(SI)(R8*2), X6 +#define MOVDDUP_8_XPTR_INCx3X__X8 LONG $0x120F46F2; WORD $0x0E44; BYTE $0x08 // MOVDDUP 8(SI)(R9*1), X8 + +#define ADDSUBPD_X2_X3 LONG $0xDAD00F66 // ADDSUBPD X2, X3 +#define ADDSUBPD_X4_X5 LONG $0xECD00F66 // ADDSUBPD X4, X5 +#define ADDSUBPD_X6_X7 LONG $0xFED00F66 // ADDSUBPD X6, X7 +#define ADDSUBPD_X8_X9 LONG $0xD00F4566; BYTE $0xC8 // ADDSUBPD X8, X9 + +#define X_PTR SI +#define Y_PTR DI +#define LEN CX +#define TAIL BX +#define SUM X0 +#define P_SUM X1 +#define INC_X R8 +#define INCx3_X R9 +#define INC_Y R10 +#define INCx3_Y R11 + +// func DotuInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) +TEXT ·DotuInc(SB), NOSPLIT, $0 + MOVQ x_base+0(FP), X_PTR // X_PTR = &x + MOVQ y_base+24(FP), Y_PTR // Y_PTR = &y + MOVQ n+48(FP), LEN // LEN = n + PXOR SUM, SUM // sum = 0 + CMPQ LEN, $0 // if LEN == 0 { return } + JE dot_end + MOVQ ix+72(FP), INC_X // INC_X = ix * sizeof(complex128) + SHLQ $4, INC_X + MOVQ iy+80(FP), INC_Y // INC_Y = iy * sizeof(complex128) + SHLQ $4, INC_Y + LEAQ (X_PTR)(INC_X*1), X_PTR // X_PTR = &(X_PTR[ix]) + LEAQ (Y_PTR)(INC_Y*1), Y_PTR // Y_PTR = &(Y_PTR[iy]) + MOVQ incX+56(FP), INC_X // INC_X = incX + SHLQ $4, INC_X // INC_X *= sizeof(complex128) + MOVQ incY+64(FP), INC_Y // INC_Y = incY + SHLQ $4, INC_Y // INC_Y *= sizeof(complex128) + MOVQ LEN, TAIL + ANDQ $3, TAIL // LEN = LEN % 4 + SHRQ $2, LEN // LEN = floor( LEN / 4 ) + JZ dot_tail // if LEN <= 4 { goto dot_tail } + PXOR P_SUM, P_SUM // psum = 0 + LEAQ (INC_X)(INC_X*2), INCx3_X // INCx3_X = 3 * incX * sizeof(complex128) + LEAQ (INC_Y)(INC_Y*2), INCx3_Y // INCx3_Y = 3 * incY * sizeof(complex128) + +dot_loop: // do { + MOVDDUP_XPTR__X3 // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_XPTR_INCX__X5 + MOVDDUP_XPTR_INCX_2__X7 + MOVDDUP_XPTR_INCx3X__X9 + + MOVDDUP_8_XPTR__X2 // X_i = { imag(x[i]), imag(x[i]) } + MOVDDUP_8_XPTR_INCX__X4 + MOVDDUP_8_XPTR_INCX_2__X6 + MOVDDUP_8_XPTR_INCx3X__X8 + + // X_j = { imag(y[i]), real(y[i]) } + MOVUPS (Y_PTR), X10 + MOVUPS (Y_PTR)(INC_Y*1), X11 + MOVUPS (Y_PTR)(INC_Y*2), X12 + MOVUPS (Y_PTR)(INCx3_Y*1), X13 + + // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + MULPD X10, X3 + MULPD X11, X5 + MULPD X12, X7 + MULPD X13, X9 + + // X_j = { real(y[i]), imag(y[i]) } + SHUFPD $0x1, X10, X10 + SHUFPD $0x1, X11, X11 + SHUFPD $0x1, X12, X12 + SHUFPD $0x1, X13, X13 + + // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + MULPD X10, X2 + MULPD X11, X4 + MULPD X12, X6 + MULPD X13, X8 + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDSUBPD_X4_X5 + ADDSUBPD_X6_X7 + ADDSUBPD_X8_X9 + + // psum += result[i] + ADDPD X3, SUM + ADDPD X5, P_SUM + ADDPD X7, SUM + ADDPD X9, P_SUM + + LEAQ (X_PTR)(INC_X*4), X_PTR // X_PTR = &(X_PTR[incX*4]) + LEAQ (Y_PTR)(INC_Y*4), Y_PTR // Y_PTR = &(Y_PTR[incY*4]) + + DECQ LEN + JNZ dot_loop // } while --BX > 0 + ADDPD P_SUM, SUM // sum += psum + CMPQ TAIL, $0 // if TAIL == 0 { return } + JE dot_end + +dot_tail: // do { + MOVDDUP_XPTR__X3 // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_8_XPTR__X2 // X_i = { imag(x[i]), imag(x[i]) } + MOVUPS (Y_PTR), X10 // X_j = { imag(y[i]) , real(y[i]) } + MULPD X10, X3 // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + SHUFPD $0x1, X10, X10 // X_j = { real(y[i]) , imag(y[i]) } + MULPD X10, X2 // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDPD X3, SUM // sum += result[i] + ADDQ INC_X, X_PTR // X_PTR += incX + ADDQ INC_Y, Y_PTR // Y_PTR += incY + DECQ TAIL // --TAIL + JNZ dot_tail // } while TAIL > 0 + +dot_end: + MOVUPS SUM, sum+88(FP) + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/dotuunitary_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/dotuunitary_amd64.s new file mode 100644 index 00000000..7f1de266 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/dotuunitary_amd64.s @@ -0,0 +1,130 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define MOVDDUP_XPTR_IDX_8__X3 LONG $0x1C120FF2; BYTE $0xC6 // MOVDDUP (SI)(AX*8), X3 +#define MOVDDUP_16_XPTR_IDX_8__X5 LONG $0x6C120FF2; WORD $0x10C6 // MOVDDUP 16(SI)(AX*8), X5 +#define MOVDDUP_32_XPTR_IDX_8__X7 LONG $0x7C120FF2; WORD $0x20C6 // MOVDDUP 32(SI)(AX*8), X7 +#define MOVDDUP_48_XPTR_IDX_8__X9 LONG $0x120F44F2; WORD $0xC64C; BYTE $0x30 // MOVDDUP 48(SI)(AX*8), X9 + +#define MOVDDUP_XPTR_IIDX_8__X2 LONG $0x14120FF2; BYTE $0xD6 // MOVDDUP (SI)(DX*8), X2 +#define MOVDDUP_16_XPTR_IIDX_8__X4 LONG $0x64120FF2; WORD $0x10D6 // MOVDDUP 16(SI)(DX*8), X4 +#define MOVDDUP_32_XPTR_IIDX_8__X6 LONG $0x74120FF2; WORD $0x20D6 // MOVDDUP 32(SI)(DX*8), X6 +#define MOVDDUP_48_XPTR_IIDX_8__X8 LONG $0x120F44F2; WORD $0xD644; BYTE $0x30 // MOVDDUP 48(SI)(DX*8), X8 + +#define ADDSUBPD_X2_X3 LONG $0xDAD00F66 // ADDSUBPD X2, X3 +#define ADDSUBPD_X4_X5 LONG $0xECD00F66 // ADDSUBPD X4, X5 +#define ADDSUBPD_X6_X7 LONG $0xFED00F66 // ADDSUBPD X6, X7 +#define ADDSUBPD_X8_X9 LONG $0xD00F4566; BYTE $0xC8 // ADDSUBPD X8, X9 + +#define X_PTR SI +#define Y_PTR DI +#define LEN CX +#define TAIL BX +#define SUM X0 +#define P_SUM X1 +#define IDX AX +#define I_IDX DX + +// func DotuUnitary(x, y []complex128) (sum complex128) +TEXT ·DotuUnitary(SB), NOSPLIT, $0 + MOVQ x_base+0(FP), X_PTR // X_PTR = &x + MOVQ y_base+24(FP), Y_PTR // Y_PTR = &y + MOVQ x_len+8(FP), LEN // LEN = min( len(x), len(y) ) + CMPQ y_len+32(FP), LEN + CMOVQLE y_len+32(FP), LEN + PXOR SUM, SUM // SUM = 0 + CMPQ LEN, $0 // if LEN == 0 { return } + JE dot_end + PXOR P_SUM, P_SUM // P_SUM = 0 + XORQ IDX, IDX // IDX = 0 + MOVQ $1, DX // j = 1 + MOVQ LEN, TAIL + ANDQ $3, TAIL // TAIL = floor( LEN / 4 ) + SHRQ $2, LEN // LEN = LEN % 4 + JZ dot_tail // if LEN == 0 { goto dot_tail } + +dot_loop: // do { + MOVDDUP_XPTR_IDX_8__X3 // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_16_XPTR_IDX_8__X5 + MOVDDUP_32_XPTR_IDX_8__X7 + MOVDDUP_48_XPTR_IDX_8__X9 + + MOVDDUP_XPTR_IIDX_8__X2 // X_i = { imag(x[i]), imag(x[i]) } + MOVDDUP_16_XPTR_IIDX_8__X4 + MOVDDUP_32_XPTR_IIDX_8__X6 + MOVDDUP_48_XPTR_IIDX_8__X8 + + // X_j = { imag(y[i]), real(y[i]) } + MOVUPS (Y_PTR)(IDX*8), X10 + MOVUPS 16(Y_PTR)(IDX*8), X11 + MOVUPS 32(Y_PTR)(IDX*8), X12 + MOVUPS 48(Y_PTR)(IDX*8), X13 + + // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + MULPD X10, X3 + MULPD X11, X5 + MULPD X12, X7 + MULPD X13, X9 + + // X_j = { real(y[i]), imag(y[i]) } + SHUFPD $0x1, X10, X10 + SHUFPD $0x1, X11, X11 + SHUFPD $0x1, X12, X12 + SHUFPD $0x1, X13, X13 + + // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + MULPD X10, X2 + MULPD X11, X4 + MULPD X12, X6 + MULPD X13, X8 + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDSUBPD_X4_X5 + ADDSUBPD_X6_X7 + ADDSUBPD_X8_X9 + + // psum += result[i] + ADDPD X3, SUM + ADDPD X5, P_SUM + ADDPD X7, SUM + ADDPD X9, P_SUM + + ADDQ $8, IDX // IDX += 8 + ADDQ $8, I_IDX // I_IDX += 8 + DECQ LEN + JNZ dot_loop // } while --LEN > 0 + ADDPD P_SUM, SUM // SUM += P_SUM + CMPQ TAIL, $0 // if TAIL == 0 { return } + JE dot_end + +dot_tail: // do { + MOVDDUP_XPTR_IDX_8__X3 // X_(i+1) = { real(x[i] , real(x[i]) } + MOVDDUP_XPTR_IIDX_8__X2 // X_i = { imag(x[i]) , imag(x[i]) } + MOVUPS (Y_PTR)(IDX*8), X10 // X_j = { imag(y[i]) , real(y[i]) } + MULPD X10, X3 // X_(i+1) = { imag(a) * real(x[i]), real(a) * real(x[i]) } + SHUFPD $0x1, X10, X10 // X_j = { real(y[i]) , imag(y[i]) } + MULPD X10, X2 // X_i = { real(a) * imag(x[i]), imag(a) * imag(x[i]) } + + // X_(i+1) = { + // imag(result[i]): imag(a)*real(x[i]) + real(a)*imag(x[i]), + // real(result[i]): real(a)*real(x[i]) - imag(a)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDPD X3, SUM // psum += result[i] + ADDQ $2, IDX // IDX += 2 + ADDQ $2, I_IDX // I_IDX += 2 + DECQ TAIL // --TAIL + JNZ dot_tail // } while TAIL > 0 + +dot_end: + MOVUPS SUM, sum+48(FP) + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/dscalinc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/dscalinc_amd64.s new file mode 100644 index 00000000..78ee18a8 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/dscalinc_amd64.s @@ -0,0 +1,69 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define SRC SI +#define DST SI +#define LEN CX +#define TAIL BX +#define INC R9 +#define INC3 R10 +#define ALPHA X0 +#define ALPHA_2 X1 + +#define MOVDDUP_ALPHA LONG $0x44120FF2; WORD $0x0824 // MOVDDUP 8(SP), X0 + +// func DscalInc(alpha float64, x []complex128, n, inc uintptr) +TEXT ·DscalInc(SB), NOSPLIT, $0 + MOVQ x_base+8(FP), SRC // SRC = &x + MOVQ n+32(FP), LEN // LEN = n + CMPQ LEN, $0 // if LEN == 0 { return } + JE dscal_end + + MOVDDUP_ALPHA // ALPHA = alpha + MOVQ inc+40(FP), INC // INC = inc + SHLQ $4, INC // INC = INC * sizeof(complex128) + LEAQ (INC)(INC*2), INC3 // INC3 = 3 * INC + MOVUPS ALPHA, ALPHA_2 // Copy ALPHA and ALPHA_2 for pipelining + MOVQ LEN, TAIL // TAIL = LEN + SHRQ $2, LEN // LEN = floor( n / 4 ) + JZ dscal_tail // if LEN == 0 { goto dscal_tail } + +dscal_loop: // do { + MOVUPS (SRC), X2 // X_i = x[i] + MOVUPS (SRC)(INC*1), X3 + MOVUPS (SRC)(INC*2), X4 + MOVUPS (SRC)(INC3*1), X5 + + MULPD ALPHA, X2 // X_i *= ALPHA + MULPD ALPHA_2, X3 + MULPD ALPHA, X4 + MULPD ALPHA_2, X5 + + MOVUPS X2, (DST) // x[i] = X_i + MOVUPS X3, (DST)(INC*1) + MOVUPS X4, (DST)(INC*2) + MOVUPS X5, (DST)(INC3*1) + + LEAQ (SRC)(INC*4), SRC // SRC += INC*4 + DECQ LEN + JNZ dscal_loop // } while --LEN > 0 + +dscal_tail: + ANDQ $3, TAIL // TAIL = TAIL % 4 + JE dscal_end // if TAIL == 0 { return } + +dscal_tail_loop: // do { + MOVUPS (SRC), X2 // X_i = x[i] + MULPD ALPHA, X2 // X_i *= ALPHA + MOVUPS X2, (DST) // x[i] = X_i + ADDQ INC, SRC // SRC += INC + DECQ TAIL + JNZ dscal_tail_loop // } while --TAIL > 0 + +dscal_end: + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/dscalunitary_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/dscalunitary_amd64.s new file mode 100644 index 00000000..c68b5a6b --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/dscalunitary_amd64.s @@ -0,0 +1,66 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define SRC SI +#define DST SI +#define LEN CX +#define IDX AX +#define TAIL BX +#define ALPHA X0 +#define ALPHA_2 X1 + +#define MOVDDUP_ALPHA LONG $0x44120FF2; WORD $0x0824 // MOVDDUP 8(SP), X0 + +// func DscalUnitary(alpha float64, x []complex128) +TEXT ·DscalUnitary(SB), NOSPLIT, $0 + MOVQ x_base+8(FP), SRC // SRC = &x + MOVQ x_len+16(FP), LEN // LEN = len(x) + CMPQ LEN, $0 // if LEN == 0 { return } + JE dscal_end + + MOVDDUP_ALPHA // ALPHA = alpha + XORQ IDX, IDX // IDX = 0 + MOVUPS ALPHA, ALPHA_2 // Copy ALPHA to ALPHA_2 for pipelining + MOVQ LEN, TAIL // TAIL = LEN + SHRQ $2, LEN // LEN = floor( n / 4 ) + JZ dscal_tail // if LEN == 0 { goto dscal_tail } + +dscal_loop: // do { + MOVUPS (SRC)(IDX*8), X2 // X_i = x[i] + MOVUPS 16(SRC)(IDX*8), X3 + MOVUPS 32(SRC)(IDX*8), X4 + MOVUPS 48(SRC)(IDX*8), X5 + + MULPD ALPHA, X2 // X_i *= ALPHA + MULPD ALPHA_2, X3 + MULPD ALPHA, X4 + MULPD ALPHA_2, X5 + + MOVUPS X2, (DST)(IDX*8) // x[i] = X_i + MOVUPS X3, 16(DST)(IDX*8) + MOVUPS X4, 32(DST)(IDX*8) + MOVUPS X5, 48(DST)(IDX*8) + + ADDQ $8, IDX // IDX += 8 + DECQ LEN + JNZ dscal_loop // } while --LEN > 0 + +dscal_tail: + ANDQ $3, TAIL // TAIL = TAIL % 4 + JZ dscal_end // if TAIL == 0 { return } + +dscal_tail_loop: // do { + MOVUPS (SRC)(IDX*8), X2 // X_i = x[i] + MULPD ALPHA, X2 // X_i *= ALPHA + MOVUPS X2, (DST)(IDX*8) // x[i] = X_i + ADDQ $2, IDX // IDX += 2 + DECQ TAIL + JNZ dscal_tail_loop // } while --TAIL > 0 + +dscal_end: + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/scal.go b/vendor/gonum.org/v1/gonum/internal/asm/c128/scal.go new file mode 100644 index 00000000..47a80e50 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/scal.go @@ -0,0 +1,31 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package c128 + +// ScalUnitaryTo is +// for i, v := range x { +// dst[i] = alpha * v +// } +func ScalUnitaryTo(dst []complex128, alpha complex128, x []complex128) { + for i, v := range x { + dst[i] = alpha * v + } +} + +// ScalIncTo is +// var idst, ix uintptr +// for i := 0; i < int(n); i++ { +// dst[idst] = alpha * x[ix] +// ix += incX +// idst += incDst +// } +func ScalIncTo(dst []complex128, incDst uintptr, alpha complex128, x []complex128, n, incX uintptr) { + var idst, ix uintptr + for i := 0; i < int(n); i++ { + dst[idst] = alpha * x[ix] + ix += incX + idst += incDst + } +} diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/scalUnitary_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/scalUnitary_amd64.s new file mode 100644 index 00000000..17c3ef46 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/scalUnitary_amd64.s @@ -0,0 +1,116 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define SRC SI +#define DST SI +#define LEN CX +#define IDX AX +#define TAIL BX +#define ALPHA X0 +#define ALPHA_C X1 +#define ALPHA2 X10 +#define ALPHA_C2 X11 + +#define MOVDDUP_X2_X3 LONG $0xDA120FF2 // MOVDDUP X2, X3 +#define MOVDDUP_X4_X5 LONG $0xEC120FF2 // MOVDDUP X4, X5 +#define MOVDDUP_X6_X7 LONG $0xFE120FF2 // MOVDDUP X6, X7 +#define MOVDDUP_X8_X9 LONG $0x120F45F2; BYTE $0xC8 // MOVDDUP X8, X9 + +#define ADDSUBPD_X2_X3 LONG $0xDAD00F66 // ADDSUBPD X2, X3 +#define ADDSUBPD_X4_X5 LONG $0xECD00F66 // ADDSUBPD X4, X5 +#define ADDSUBPD_X6_X7 LONG $0xFED00F66 // ADDSUBPD X6, X7 +#define ADDSUBPD_X8_X9 LONG $0xD00F4566; BYTE $0xC8 // ADDSUBPD X8, X9 + +// func ScalUnitary(alpha complex128, x []complex128) +TEXT ·ScalUnitary(SB), NOSPLIT, $0 + MOVQ x_base+16(FP), SRC // SRC = &x + MOVQ x_len+24(FP), LEN // LEN = len(x) + CMPQ LEN, $0 // if LEN == 0 { return } + JE scal_end + + MOVUPS alpha+0(FP), ALPHA // ALPHA = { imag(alpha), real(alpha) } + MOVAPS ALPHA, ALPHA_C + SHUFPD $0x1, ALPHA_C, ALPHA_C // ALPHA_C = { real(alpha), imag(alpha) } + + XORQ IDX, IDX // IDX = 0 + MOVAPS ALPHA, ALPHA2 // Copy ALPHA and ALPHA_C for pipelining + MOVAPS ALPHA_C, ALPHA_C2 + MOVQ LEN, TAIL + SHRQ $2, LEN // LEN = floor( n / 4 ) + JZ scal_tail // if BX == 0 { goto scal_tail } + +scal_loop: // do { + MOVUPS (SRC)(IDX*8), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVUPS 16(SRC)(IDX*8), X4 + MOVUPS 32(SRC)(IDX*8), X6 + MOVUPS 48(SRC)(IDX*8), X8 + + // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_X2_X3 + MOVDDUP_X4_X5 + MOVDDUP_X6_X7 + MOVDDUP_X8_X9 + + // X_i = { imag(x[i]), imag(x[i]) } + SHUFPD $0x3, X2, X2 + SHUFPD $0x3, X4, X4 + SHUFPD $0x3, X6, X6 + SHUFPD $0x3, X8, X8 + + // X_i = { real(ALPHA) * imag(x[i]), imag(ALPHA) * imag(x[i]) } + // X_(i+1) = { imag(ALPHA) * real(x[i]), real(ALPHA) * real(x[i]) } + MULPD ALPHA_C, X2 + MULPD ALPHA, X3 + MULPD ALPHA_C2, X4 + MULPD ALPHA2, X5 + MULPD ALPHA_C, X6 + MULPD ALPHA, X7 + MULPD ALPHA_C2, X8 + MULPD ALPHA2, X9 + + // X_(i+1) = { + // imag(result[i]): imag(ALPHA)*real(x[i]) + real(ALPHA)*imag(x[i]), + // real(result[i]): real(ALPHA)*real(x[i]) - imag(ALPHA)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDSUBPD_X4_X5 + ADDSUBPD_X6_X7 + ADDSUBPD_X8_X9 + + MOVUPS X3, (DST)(IDX*8) // x[i] = X_(i+1) + MOVUPS X5, 16(DST)(IDX*8) + MOVUPS X7, 32(DST)(IDX*8) + MOVUPS X9, 48(DST)(IDX*8) + ADDQ $8, IDX // IDX += 8 + DECQ LEN + JNZ scal_loop // } while --LEN > 0 + +scal_tail: + ANDQ $3, TAIL // TAIL = TAIL % 4 + JZ scal_end // if TAIL == 0 { return } + +scal_tail_loop: // do { + MOVUPS (SRC)(IDX*8), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVDDUP_X2_X3 // X_(i+1) = { real(x[i], real(x[i]) } + SHUFPD $0x3, X2, X2 // X_i = { imag(x[i]), imag(x[i]) } + MULPD ALPHA_C, X2 // X_i = { real(ALPHA) * imag(x[i]), imag(ALPHA) * imag(x[i]) } + MULPD ALPHA, X3 // X_(i+1) = { imag(ALPHA) * real(x[i]), real(ALPHA) * real(x[i]) } + + // X_(i+1) = { + // imag(result[i]): imag(ALPHA)*real(x[i]) + real(ALPHA)*imag(x[i]), + // real(result[i]): real(ALPHA)*real(x[i]) - imag(ALPHA)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + + MOVUPS X3, (DST)(IDX*8) // x[i] = X_(i+1) + ADDQ $2, IDX // IDX += 2 + DECQ TAIL + JNZ scal_tail_loop // } while --LEN > 0 + +scal_end: + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/scalinc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/c128/scalinc_amd64.s new file mode 100644 index 00000000..17884cb6 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/scalinc_amd64.s @@ -0,0 +1,121 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define SRC SI +#define DST SI +#define LEN CX +#define TAIL BX +#define INC R9 +#define INC3 R10 +#define ALPHA X0 +#define ALPHA_C X1 +#define ALPHA2 X10 +#define ALPHA_C2 X11 + +#define MOVDDUP_X2_X3 LONG $0xDA120FF2 // MOVDDUP X2, X3 +#define MOVDDUP_X4_X5 LONG $0xEC120FF2 // MOVDDUP X4, X5 +#define MOVDDUP_X6_X7 LONG $0xFE120FF2 // MOVDDUP X6, X7 +#define MOVDDUP_X8_X9 LONG $0x120F45F2; BYTE $0xC8 // MOVDDUP X8, X9 + +#define ADDSUBPD_X2_X3 LONG $0xDAD00F66 // ADDSUBPD X2, X3 +#define ADDSUBPD_X4_X5 LONG $0xECD00F66 // ADDSUBPD X4, X5 +#define ADDSUBPD_X6_X7 LONG $0xFED00F66 // ADDSUBPD X6, X7 +#define ADDSUBPD_X8_X9 LONG $0xD00F4566; BYTE $0xC8 // ADDSUBPD X8, X9 + +// func ScalInc(alpha complex128, x []complex128, n, inc uintptr) +TEXT ·ScalInc(SB), NOSPLIT, $0 + MOVQ x_base+16(FP), SRC // SRC = &x + MOVQ n+40(FP), LEN // LEN = len(x) + CMPQ LEN, $0 + JE scal_end // if LEN == 0 { return } + + MOVQ inc+48(FP), INC // INC = inc + SHLQ $4, INC // INC = INC * sizeof(complex128) + LEAQ (INC)(INC*2), INC3 // INC3 = 3 * INC + + MOVUPS alpha+0(FP), ALPHA // ALPHA = { imag(alpha), real(alpha) } + MOVAPS ALPHA, ALPHA_C + SHUFPD $0x1, ALPHA_C, ALPHA_C // ALPHA_C = { real(alpha), imag(alpha) } + + MOVAPS ALPHA, ALPHA2 // Copy ALPHA and ALPHA_C for pipelining + MOVAPS ALPHA_C, ALPHA_C2 + MOVQ LEN, TAIL + SHRQ $2, LEN // LEN = floor( n / 4 ) + JZ scal_tail // if BX == 0 { goto scal_tail } + +scal_loop: // do { + MOVUPS (SRC), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVUPS (SRC)(INC*1), X4 + MOVUPS (SRC)(INC*2), X6 + MOVUPS (SRC)(INC3*1), X8 + + // X_(i+1) = { real(x[i], real(x[i]) } + MOVDDUP_X2_X3 + MOVDDUP_X4_X5 + MOVDDUP_X6_X7 + MOVDDUP_X8_X9 + + // X_i = { imag(x[i]), imag(x[i]) } + SHUFPD $0x3, X2, X2 + SHUFPD $0x3, X4, X4 + SHUFPD $0x3, X6, X6 + SHUFPD $0x3, X8, X8 + + // X_i = { real(ALPHA) * imag(x[i]), imag(ALPHA) * imag(x[i]) } + // X_(i+1) = { imag(ALPHA) * real(x[i]), real(ALPHA) * real(x[i]) } + MULPD ALPHA_C, X2 + MULPD ALPHA, X3 + MULPD ALPHA_C2, X4 + MULPD ALPHA2, X5 + MULPD ALPHA_C, X6 + MULPD ALPHA, X7 + MULPD ALPHA_C2, X8 + MULPD ALPHA2, X9 + + // X_(i+1) = { + // imag(result[i]): imag(ALPHA)*real(x[i]) + real(ALPHA)*imag(x[i]), + // real(result[i]): real(ALPHA)*real(x[i]) - imag(ALPHA)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + ADDSUBPD_X4_X5 + ADDSUBPD_X6_X7 + ADDSUBPD_X8_X9 + + MOVUPS X3, (DST) // x[i] = X_(i+1) + MOVUPS X5, (DST)(INC*1) + MOVUPS X7, (DST)(INC*2) + MOVUPS X9, (DST)(INC3*1) + + LEAQ (SRC)(INC*4), SRC // SRC = &(SRC[inc*4]) + DECQ LEN + JNZ scal_loop // } while --BX > 0 + +scal_tail: + ANDQ $3, TAIL // TAIL = TAIL % 4 + JE scal_end // if TAIL == 0 { return } + +scal_tail_loop: // do { + MOVUPS (SRC), X2 // X_i = { imag(x[i]), real(x[i]) } + MOVDDUP_X2_X3 // X_(i+1) = { real(x[i], real(x[i]) } + SHUFPD $0x3, X2, X2 // X_i = { imag(x[i]), imag(x[i]) } + MULPD ALPHA_C, X2 // X_i = { real(ALPHA) * imag(x[i]), imag(ALPHA) * imag(x[i]) } + MULPD ALPHA, X3 // X_(i+1) = { imag(ALPHA) * real(x[i]), real(ALPHA) * real(x[i]) } + + // X_(i+1) = { + // imag(result[i]): imag(ALPHA)*real(x[i]) + real(ALPHA)*imag(x[i]), + // real(result[i]): real(ALPHA)*real(x[i]) - imag(ALPHA)*imag(x[i]) + // } + ADDSUBPD_X2_X3 + + MOVUPS X3, (DST) // x[i] = X_i + ADDQ INC, SRC // SRC = &(SRC[incX]) + DECQ TAIL + JNZ scal_tail_loop // } while --TAIL > 0 + +scal_end: + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/stubs_amd64.go b/vendor/gonum.org/v1/gonum/internal/asm/c128/stubs_amd64.go new file mode 100644 index 00000000..c03df58b --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/stubs_amd64.go @@ -0,0 +1,96 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +package c128 + +// AxpyUnitary is +// for i, v := range x { +// y[i] += alpha * v +// } +func AxpyUnitary(alpha complex128, x, y []complex128) + +// AxpyUnitaryTo is +// for i, v := range x { +// dst[i] = alpha*v + y[i] +// } +func AxpyUnitaryTo(dst []complex128, alpha complex128, x, y []complex128) + +// AxpyInc is +// for i := 0; i < int(n); i++ { +// y[iy] += alpha * x[ix] +// ix += incX +// iy += incY +// } +func AxpyInc(alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) + +// AxpyIncTo is +// for i := 0; i < int(n); i++ { +// dst[idst] = alpha*x[ix] + y[iy] +// ix += incX +// iy += incY +// idst += incDst +// } +func AxpyIncTo(dst []complex128, incDst, idst uintptr, alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) + +// DscalUnitary is +// for i, v := range x { +// x[i] = complex(real(v)*alpha, imag(v)*alpha) +// } +func DscalUnitary(alpha float64, x []complex128) + +// DscalInc is +// var ix uintptr +// for i := 0; i < int(n); i++ { +// x[ix] = complex(real(x[ix])*alpha, imag(x[ix])*alpha) +// ix += inc +// } +func DscalInc(alpha float64, x []complex128, n, inc uintptr) + +// ScalInc is +// var ix uintptr +// for i := 0; i < int(n); i++ { +// x[ix] *= alpha +// ix += incX +// } +func ScalInc(alpha complex128, x []complex128, n, inc uintptr) + +// ScalUnitary is +// for i := range x { +// x[i] *= alpha +// } +func ScalUnitary(alpha complex128, x []complex128) + +// DotcUnitary is +// for i, v := range x { +// sum += y[i] * cmplx.Conj(v) +// } +// return sum +func DotcUnitary(x, y []complex128) (sum complex128) + +// DotcInc is +// for i := 0; i < int(n); i++ { +// sum += y[iy] * cmplx.Conj(x[ix]) +// ix += incX +// iy += incY +// } +// return sum +func DotcInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) + +// DotuUnitary is +// for i, v := range x { +// sum += y[i] * v +// } +// return sum +func DotuUnitary(x, y []complex128) (sum complex128) + +// DotuInc is +// for i := 0; i < int(n); i++ { +// sum += y[iy] * x[ix] +// ix += incX +// iy += incY +// } +// return sum +func DotuInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) diff --git a/vendor/gonum.org/v1/gonum/internal/asm/c128/stubs_noasm.go b/vendor/gonum.org/v1/gonum/internal/asm/c128/stubs_noasm.go new file mode 100644 index 00000000..92abe0d9 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/c128/stubs_noasm.go @@ -0,0 +1,163 @@ +// Copyright ©2016 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !amd64 noasm appengine + +package c128 + +import "math/cmplx" + +// AxpyUnitary is +// for i, v := range x { +// y[i] += alpha * v +// } +func AxpyUnitary(alpha complex128, x, y []complex128) { + for i, v := range x { + y[i] += alpha * v + } +} + +// AxpyUnitaryTo is +// for i, v := range x { +// dst[i] = alpha*v + y[i] +// } +func AxpyUnitaryTo(dst []complex128, alpha complex128, x, y []complex128) { + for i, v := range x { + dst[i] = alpha*v + y[i] + } +} + +// AxpyInc is +// for i := 0; i < int(n); i++ { +// y[iy] += alpha * x[ix] +// ix += incX +// iy += incY +// } +func AxpyInc(alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) { + for i := 0; i < int(n); i++ { + y[iy] += alpha * x[ix] + ix += incX + iy += incY + } +} + +// AxpyIncTo is +// for i := 0; i < int(n); i++ { +// dst[idst] = alpha*x[ix] + y[iy] +// ix += incX +// iy += incY +// idst += incDst +// } +func AxpyIncTo(dst []complex128, incDst, idst uintptr, alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) { + for i := 0; i < int(n); i++ { + dst[idst] = alpha*x[ix] + y[iy] + ix += incX + iy += incY + idst += incDst + } +} + +// DscalUnitary is +// for i, v := range x { +// x[i] = complex(real(v)*alpha, imag(v)*alpha) +// } +func DscalUnitary(alpha float64, x []complex128) { + for i, v := range x { + x[i] = complex(real(v)*alpha, imag(v)*alpha) + } +} + +// DscalInc is +// var ix uintptr +// for i := 0; i < int(n); i++ { +// x[ix] = complex(real(x[ix])*alpha, imag(x[ix])*alpha) +// ix += inc +// } +func DscalInc(alpha float64, x []complex128, n, inc uintptr) { + var ix uintptr + for i := 0; i < int(n); i++ { + x[ix] = complex(real(x[ix])*alpha, imag(x[ix])*alpha) + ix += inc + } +} + +// ScalInc is +// var ix uintptr +// for i := 0; i < int(n); i++ { +// x[ix] *= alpha +// ix += incX +// } +func ScalInc(alpha complex128, x []complex128, n, inc uintptr) { + var ix uintptr + for i := 0; i < int(n); i++ { + x[ix] *= alpha + ix += inc + } +} + +// ScalUnitary is +// for i := range x { +// x[i] *= alpha +// } +func ScalUnitary(alpha complex128, x []complex128) { + for i := range x { + x[i] *= alpha + } +} + +// DotcUnitary is +// for i, v := range x { +// sum += y[i] * cmplx.Conj(v) +// } +// return sum +func DotcUnitary(x, y []complex128) (sum complex128) { + for i, v := range x { + sum += y[i] * cmplx.Conj(v) + } + return sum +} + +// DotcInc is +// for i := 0; i < int(n); i++ { +// sum += y[iy] * cmplx.Conj(x[ix]) +// ix += incX +// iy += incY +// } +// return sum +func DotcInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) { + for i := 0; i < int(n); i++ { + sum += y[iy] * cmplx.Conj(x[ix]) + ix += incX + iy += incY + } + return sum +} + +// DotuUnitary is +// for i, v := range x { +// sum += y[i] * v +// } +// return sum +func DotuUnitary(x, y []complex128) (sum complex128) { + for i, v := range x { + sum += y[i] * v + } + return sum +} + +// DotuInc is +// for i := 0; i < int(n); i++ { +// sum += y[iy] * x[ix] +// ix += incX +// iy += incY +// } +// return sum +func DotuInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) { + for i := 0; i < int(n); i++ { + sum += y[iy] * x[ix] + ix += incX + iy += incY + } + return sum +} diff --git a/vendor/github.com/gonum/internal/asm/f32/axpyinc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f32/axpyinc_amd64.s similarity index 97% rename from vendor/github.com/gonum/internal/asm/f32/axpyinc_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f32/axpyinc_amd64.s index a6462f0e..2b3126f4 100644 --- a/vendor/github.com/gonum/internal/asm/f32/axpyinc_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/axpyinc_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f32/axpyincto_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f32/axpyincto_amd64.s similarity index 97% rename from vendor/github.com/gonum/internal/asm/f32/axpyincto_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f32/axpyincto_amd64.s index e1c39e90..8100a750 100644 --- a/vendor/github.com/gonum/internal/asm/f32/axpyincto_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/axpyincto_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f32/axpyunitary_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f32/axpyunitary_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f32/axpyunitary_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f32/axpyunitary_amd64.s index a5bfaac9..d14230b9 100644 --- a/vendor/github.com/gonum/internal/asm/f32/axpyunitary_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/axpyunitary_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f32/axpyunitaryto_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f32/axpyunitaryto_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f32/axpyunitaryto_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f32/axpyunitaryto_amd64.s index 9a8289f8..0ed8a449 100644 --- a/vendor/github.com/gonum/internal/asm/f32/axpyunitaryto_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/axpyunitaryto_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/gonum.org/v1/gonum/internal/asm/f32/ddotinc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f32/ddotinc_amd64.s new file mode 100644 index 00000000..68c7fa9d --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/ddotinc_amd64.s @@ -0,0 +1,91 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define X_PTR SI +#define Y_PTR DI +#define LEN CX +#define TAIL BX +#define INC_X R8 +#define INCx3_X R10 +#define INC_Y R9 +#define INCx3_Y R11 +#define SUM X0 +#define P_SUM X1 + +// func DdotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float64) +TEXT ·DdotInc(SB), NOSPLIT, $0 + MOVQ x_base+0(FP), X_PTR // X_PTR = &x + MOVQ y_base+24(FP), Y_PTR // Y_PTR = &y + MOVQ n+48(FP), LEN // LEN = n + PXOR SUM, SUM // SUM = 0 + CMPQ LEN, $0 + JE dot_end + + MOVQ ix+72(FP), INC_X // INC_X = ix + MOVQ iy+80(FP), INC_Y // INC_Y = iy + LEAQ (X_PTR)(INC_X*4), X_PTR // X_PTR = &(x[ix]) + LEAQ (Y_PTR)(INC_Y*4), Y_PTR // Y_PTR = &(y[iy]) + + MOVQ incX+56(FP), INC_X // INC_X = incX * sizeof(float32) + SHLQ $2, INC_X + MOVQ incY+64(FP), INC_Y // INC_Y = incY * sizeof(float32) + SHLQ $2, INC_Y + + MOVQ LEN, TAIL + ANDQ $3, TAIL // TAIL = LEN % 4 + SHRQ $2, LEN // LEN = floor( LEN / 4 ) + JZ dot_tail // if LEN == 0 { goto dot_tail } + + PXOR P_SUM, P_SUM // P_SUM = 0 for pipelining + LEAQ (INC_X)(INC_X*2), INCx3_X // INCx3_X = INC_X * 3 + LEAQ (INC_Y)(INC_Y*2), INCx3_Y // INCx3_Y = INC_Y * 3 + +dot_loop: // Loop unrolled 4x do { + CVTSS2SD (X_PTR), X2 // X_i = x[i:i+1] + CVTSS2SD (X_PTR)(INC_X*1), X3 + CVTSS2SD (X_PTR)(INC_X*2), X4 + CVTSS2SD (X_PTR)(INCx3_X*1), X5 + + CVTSS2SD (Y_PTR), X6 // X_j = y[i:i+1] + CVTSS2SD (Y_PTR)(INC_Y*1), X7 + CVTSS2SD (Y_PTR)(INC_Y*2), X8 + CVTSS2SD (Y_PTR)(INCx3_Y*1), X9 + + MULSD X6, X2 // X_i *= X_j + MULSD X7, X3 + MULSD X8, X4 + MULSD X9, X5 + + ADDSD X2, SUM // SUM += X_i + ADDSD X3, P_SUM + ADDSD X4, SUM + ADDSD X5, P_SUM + + LEAQ (X_PTR)(INC_X*4), X_PTR // X_PTR = &(X_PTR[INC_X * 4]) + LEAQ (Y_PTR)(INC_Y*4), Y_PTR // Y_PTR = &(Y_PTR[INC_Y * 4]) + + DECQ LEN + JNZ dot_loop // } while --LEN > 0 + + ADDSD P_SUM, SUM // SUM += P_SUM + CMPQ TAIL, $0 // if TAIL == 0 { return } + JE dot_end + +dot_tail: // do { + CVTSS2SD (X_PTR), X2 // X2 = x[i] + CVTSS2SD (Y_PTR), X3 // X2 *= y[i] + MULSD X3, X2 + ADDSD X2, SUM // SUM += X2 + ADDQ INC_X, X_PTR // X_PTR += INC_X + ADDQ INC_Y, Y_PTR // Y_PTR += INC_Y + DECQ TAIL + JNZ dot_tail // } while --TAIL > 0 + +dot_end: + MOVSD SUM, sum+88(FP) // return SUM + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/f32/ddotunitary_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f32/ddotunitary_amd64.s new file mode 100644 index 00000000..47d24ab5 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/ddotunitary_amd64.s @@ -0,0 +1,110 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define HADDPD_SUM_SUM LONG $0xC07C0F66 // @ HADDPD X0, X0 + +#define X_PTR SI +#define Y_PTR DI +#define LEN CX +#define TAIL BX +#define IDX AX +#define SUM X0 +#define P_SUM X1 + +// func DdotUnitary(x, y []float32) (sum float32) +TEXT ·DdotUnitary(SB), NOSPLIT, $0 + MOVQ x_base+0(FP), X_PTR // X_PTR = &x + MOVQ y_base+24(FP), Y_PTR // Y_PTR = &y + MOVQ x_len+8(FP), LEN // LEN = min( len(x), len(y) ) + CMPQ y_len+32(FP), LEN + CMOVQLE y_len+32(FP), LEN + PXOR SUM, SUM // psum = 0 + CMPQ LEN, $0 + JE dot_end + + XORQ IDX, IDX + MOVQ Y_PTR, DX + ANDQ $0xF, DX // Align on 16-byte boundary for ADDPS + JZ dot_no_trim // if DX == 0 { goto dot_no_trim } + + SUBQ $16, DX + +dot_align: // Trim first value(s) in unaligned buffer do { + CVTSS2SD (X_PTR)(IDX*4), X2 // X2 = float64(x[i]) + CVTSS2SD (Y_PTR)(IDX*4), X3 // X3 = float64(y[i]) + MULSD X3, X2 + ADDSD X2, SUM // SUM += X2 + INCQ IDX // IDX++ + DECQ LEN + JZ dot_end // if --TAIL == 0 { return } + ADDQ $4, DX + JNZ dot_align // } while --LEN > 0 + +dot_no_trim: + PXOR P_SUM, P_SUM // P_SUM = 0 for pipelining + MOVQ LEN, TAIL + ANDQ $0x7, TAIL // TAIL = LEN % 8 + SHRQ $3, LEN // LEN = floor( LEN / 8 ) + JZ dot_tail_start // if LEN == 0 { goto dot_tail_start } + +dot_loop: // Loop unrolled 8x do { + CVTPS2PD (X_PTR)(IDX*4), X2 // X_i = x[i:i+1] + CVTPS2PD 8(X_PTR)(IDX*4), X3 + CVTPS2PD 16(X_PTR)(IDX*4), X4 + CVTPS2PD 24(X_PTR)(IDX*4), X5 + + CVTPS2PD (Y_PTR)(IDX*4), X6 // X_j = y[i:i+1] + CVTPS2PD 8(Y_PTR)(IDX*4), X7 + CVTPS2PD 16(Y_PTR)(IDX*4), X8 + CVTPS2PD 24(Y_PTR)(IDX*4), X9 + + MULPD X6, X2 // X_i *= X_j + MULPD X7, X3 + MULPD X8, X4 + MULPD X9, X5 + + ADDPD X2, SUM // SUM += X_i + ADDPD X3, P_SUM + ADDPD X4, SUM + ADDPD X5, P_SUM + + ADDQ $8, IDX // IDX += 8 + DECQ LEN + JNZ dot_loop // } while --LEN > 0 + + ADDPD P_SUM, SUM // SUM += P_SUM + CMPQ TAIL, $0 // if TAIL == 0 { return } + JE dot_end + +dot_tail_start: + MOVQ TAIL, LEN + SHRQ $1, LEN + JZ dot_tail_one + +dot_tail_two: + CVTPS2PD (X_PTR)(IDX*4), X2 // X_i = x[i:i+1] + CVTPS2PD (Y_PTR)(IDX*4), X6 // X_j = y[i:i+1] + MULPD X6, X2 // X_i *= X_j + ADDPD X2, SUM // SUM += X_i + ADDQ $2, IDX // IDX += 2 + DECQ LEN + JNZ dot_tail_two // } while --LEN > 0 + + ANDQ $1, TAIL + JZ dot_end + +dot_tail_one: + CVTSS2SD (X_PTR)(IDX*4), X2 // X2 = float64(x[i]) + CVTSS2SD (Y_PTR)(IDX*4), X3 // X3 = float64(y[i]) + MULSD X3, X2 // X2 *= X3 + ADDSD X2, SUM // SUM += X2 + +dot_end: + HADDPD_SUM_SUM // SUM = \sum{ SUM[i] } + MOVSD SUM, sum+48(FP) // return SUM + RET diff --git a/vendor/github.com/gonum/internal/asm/f32/doc.go b/vendor/gonum.org/v1/gonum/internal/asm/f32/doc.go similarity index 56% rename from vendor/github.com/gonum/internal/asm/f32/doc.go rename to vendor/gonum.org/v1/gonum/internal/asm/f32/doc.go index e7e1d9f8..408847a6 100644 --- a/vendor/github.com/gonum/internal/asm/f32/doc.go +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/doc.go @@ -1,6 +1,6 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package f32 provides float32 vector primitives. -package f32 +package f32 // import "gonum.org/v1/gonum/internal/asm/f32" diff --git a/vendor/gonum.org/v1/gonum/internal/asm/f32/dotinc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f32/dotinc_amd64.s new file mode 100644 index 00000000..00a382b5 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/dotinc_amd64.s @@ -0,0 +1,85 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define X_PTR SI +#define Y_PTR DI +#define LEN CX +#define TAIL BX +#define INC_X R8 +#define INCx3_X R10 +#define INC_Y R9 +#define INCx3_Y R11 +#define SUM X0 +#define P_SUM X1 + +// func DotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float32) +TEXT ·DotInc(SB), NOSPLIT, $0 + MOVQ x_base+0(FP), X_PTR // X_PTR = &x + MOVQ y_base+24(FP), Y_PTR // Y_PTR = &y + PXOR SUM, SUM // SUM = 0 + MOVQ n+48(FP), LEN // LEN = n + CMPQ LEN, $0 + JE dot_end + + MOVQ ix+72(FP), INC_X // INC_X = ix + MOVQ iy+80(FP), INC_Y // INC_Y = iy + LEAQ (X_PTR)(INC_X*4), X_PTR // X_PTR = &(x[ix]) + LEAQ (Y_PTR)(INC_Y*4), Y_PTR // Y_PTR = &(y[iy]) + + MOVQ incX+56(FP), INC_X // INC_X := incX * sizeof(float32) + SHLQ $2, INC_X + MOVQ incY+64(FP), INC_Y // INC_Y := incY * sizeof(float32) + SHLQ $2, INC_Y + + MOVQ LEN, TAIL + ANDQ $0x3, TAIL // TAIL = LEN % 4 + SHRQ $2, LEN // LEN = floor( LEN / 4 ) + JZ dot_tail // if LEN == 0 { goto dot_tail } + + PXOR P_SUM, P_SUM // P_SUM = 0 for pipelining + LEAQ (INC_X)(INC_X*2), INCx3_X // INCx3_X = INC_X * 3 + LEAQ (INC_Y)(INC_Y*2), INCx3_Y // INCx3_Y = INC_Y * 3 + +dot_loop: // Loop unrolled 4x do { + MOVSS (X_PTR), X2 // X_i = x[i:i+1] + MOVSS (X_PTR)(INC_X*1), X3 + MOVSS (X_PTR)(INC_X*2), X4 + MOVSS (X_PTR)(INCx3_X*1), X5 + + MULSS (Y_PTR), X2 // X_i *= y[i:i+1] + MULSS (Y_PTR)(INC_Y*1), X3 + MULSS (Y_PTR)(INC_Y*2), X4 + MULSS (Y_PTR)(INCx3_Y*1), X5 + + ADDSS X2, SUM // SUM += X_i + ADDSS X3, P_SUM + ADDSS X4, SUM + ADDSS X5, P_SUM + + LEAQ (X_PTR)(INC_X*4), X_PTR // X_PTR = &(X_PTR[INC_X * 4]) + LEAQ (Y_PTR)(INC_Y*4), Y_PTR // Y_PTR = &(Y_PTR[INC_Y * 4]) + + DECQ LEN + JNZ dot_loop // } while --LEN > 0 + + ADDSS P_SUM, SUM // P_SUM += SUM + CMPQ TAIL, $0 // if TAIL == 0 { return } + JE dot_end + +dot_tail: // do { + MOVSS (X_PTR), X2 // X2 = x[i] + MULSS (Y_PTR), X2 // X2 *= y[i] + ADDSS X2, SUM // SUM += X2 + ADDQ INC_X, X_PTR // X_PTR += INC_X + ADDQ INC_Y, Y_PTR // Y_PTR += INC_Y + DECQ TAIL + JNZ dot_tail // } while --TAIL > 0 + +dot_end: + MOVSS SUM, sum+88(FP) // return SUM + RET diff --git a/vendor/gonum.org/v1/gonum/internal/asm/f32/dotunitary_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f32/dotunitary_amd64.s new file mode 100644 index 00000000..581a8f4c --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/dotunitary_amd64.s @@ -0,0 +1,106 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !noasm,!appengine + +#include "textflag.h" + +#define HADDPS_SUM_SUM LONG $0xC07C0FF2 // @ HADDPS X0, X0 + +#define X_PTR SI +#define Y_PTR DI +#define LEN CX +#define TAIL BX +#define IDX AX +#define SUM X0 +#define P_SUM X1 + +// func DotUnitary(x, y []float32) (sum float32) +TEXT ·DotUnitary(SB), NOSPLIT, $0 + MOVQ x_base+0(FP), X_PTR // X_PTR = &x + MOVQ y_base+24(FP), Y_PTR // Y_PTR = &y + PXOR SUM, SUM // SUM = 0 + MOVQ x_len+8(FP), LEN // LEN = min( len(x), len(y) ) + CMPQ y_len+32(FP), LEN + CMOVQLE y_len+32(FP), LEN + CMPQ LEN, $0 + JE dot_end + + XORQ IDX, IDX + MOVQ Y_PTR, DX + ANDQ $0xF, DX // Align on 16-byte boundary for MULPS + JZ dot_no_trim // if DX == 0 { goto dot_no_trim } + SUBQ $16, DX + +dot_align: // Trim first value(s) in unaligned buffer do { + MOVSS (X_PTR)(IDX*4), X2 // X2 = x[i] + MULSS (Y_PTR)(IDX*4), X2 // X2 *= y[i] + ADDSS X2, SUM // SUM += X2 + INCQ IDX // IDX++ + DECQ LEN + JZ dot_end // if --TAIL == 0 { return } + ADDQ $4, DX + JNZ dot_align // } while --DX > 0 + +dot_no_trim: + PXOR P_SUM, P_SUM // P_SUM = 0 for pipelining + MOVQ LEN, TAIL + ANDQ $0xF, TAIL // TAIL = LEN % 16 + SHRQ $4, LEN // LEN = floor( LEN / 16 ) + JZ dot_tail4_start // if LEN == 0 { goto dot_tail4_start } + +dot_loop: // Loop unrolled 16x do { + MOVUPS (X_PTR)(IDX*4), X2 // X_i = x[i:i+1] + MOVUPS 16(X_PTR)(IDX*4), X3 + MOVUPS 32(X_PTR)(IDX*4), X4 + MOVUPS 48(X_PTR)(IDX*4), X5 + + MULPS (Y_PTR)(IDX*4), X2 // X_i *= y[i:i+1] + MULPS 16(Y_PTR)(IDX*4), X3 + MULPS 32(Y_PTR)(IDX*4), X4 + MULPS 48(Y_PTR)(IDX*4), X5 + + ADDPS X2, SUM // SUM += X_i + ADDPS X3, P_SUM + ADDPS X4, SUM + ADDPS X5, P_SUM + + ADDQ $16, IDX // IDX += 16 + DECQ LEN + JNZ dot_loop // } while --LEN > 0 + + ADDPS P_SUM, SUM // SUM += P_SUM + CMPQ TAIL, $0 // if TAIL == 0 { return } + JE dot_end + +dot_tail4_start: // Reset loop counter for 4-wide tail loop + MOVQ TAIL, LEN // LEN = floor( TAIL / 4 ) + SHRQ $2, LEN + JZ dot_tail_start // if LEN == 0 { goto dot_tail_start } + +dot_tail4_loop: // Loop unrolled 4x do { + MOVUPS (X_PTR)(IDX*4), X2 // X_i = x[i:i+1] + MULPS (Y_PTR)(IDX*4), X2 // X_i *= y[i:i+1] + ADDPS X2, SUM // SUM += X_i + ADDQ $4, IDX // i += 4 + DECQ LEN + JNZ dot_tail4_loop // } while --LEN > 0 + +dot_tail_start: // Reset loop counter for 1-wide tail loop + ANDQ $3, TAIL // TAIL = TAIL % 4 + JZ dot_end // if TAIL == 0 { return } + +dot_tail: // do { + MOVSS (X_PTR)(IDX*4), X2 // X2 = x[i] + MULSS (Y_PTR)(IDX*4), X2 // X2 *= y[i] + ADDSS X2, SUM // psum += X2 + INCQ IDX // IDX++ + DECQ TAIL + JNZ dot_tail // } while --TAIL > 0 + +dot_end: + HADDPS_SUM_SUM // SUM = \sum{ SUM[i] } + HADDPS_SUM_SUM + MOVSS SUM, sum+48(FP) // return SUM + RET diff --git a/vendor/github.com/gonum/internal/asm/f32/scal.go b/vendor/gonum.org/v1/gonum/internal/asm/f32/scal.go similarity index 94% rename from vendor/github.com/gonum/internal/asm/f32/scal.go rename to vendor/gonum.org/v1/gonum/internal/asm/f32/scal.go index c4f61e87..d0867a46 100644 --- a/vendor/github.com/gonum/internal/asm/f32/scal.go +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/scal.go @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f32/stubs_amd64.go b/vendor/gonum.org/v1/gonum/internal/asm/f32/stubs_amd64.go similarity index 53% rename from vendor/github.com/gonum/internal/asm/f32/stubs_amd64.go rename to vendor/gonum.org/v1/gonum/internal/asm/f32/stubs_amd64.go index 00ad520a..111f99a9 100644 --- a/vendor/github.com/gonum/internal/asm/f32/stubs_amd64.go +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/stubs_amd64.go @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -34,3 +34,35 @@ func AxpyInc(alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr) // idst += incDst // } func AxpyIncTo(dst []float32, incDst, idst uintptr, alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr) + +// DdotUnitary is +// for i, v := range x { +// sum += float64(y[i]) * float64(v) +// } +// return +func DdotUnitary(x, y []float32) (sum float64) + +// DdotInc is +// for i := 0; i < int(n); i++ { +// sum += float64(y[iy]) * float64(x[ix]) +// ix += incX +// iy += incY +// } +// return +func DdotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float64) + +// DotUnitary is +// for i, v := range x { +// sum += y[i] * v +// } +// return sum +func DotUnitary(x, y []float32) (sum float32) + +// DotInc is +// for i := 0; i < int(n); i++ { +// sum += y[iy] * x[ix] +// ix += incX +// iy += incY +// } +// return sum +func DotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float32) diff --git a/vendor/github.com/gonum/internal/asm/f32/stubs_noasm.go b/vendor/gonum.org/v1/gonum/internal/asm/f32/stubs_noasm.go similarity index 51% rename from vendor/github.com/gonum/internal/asm/f32/stubs_noasm.go rename to vendor/gonum.org/v1/gonum/internal/asm/f32/stubs_noasm.go index a6272ea5..55e21e4a 100644 --- a/vendor/github.com/gonum/internal/asm/f32/stubs_noasm.go +++ b/vendor/gonum.org/v1/gonum/internal/asm/f32/stubs_noasm.go @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -55,3 +55,59 @@ func AxpyIncTo(dst []float32, incDst, idst uintptr, alpha float32, x, y []float3 idst += incDst } } + +// DotUnitary is +// for i, v := range x { +// sum += y[i] * v +// } +// return sum +func DotUnitary(x, y []float32) (sum float32) { + for i, v := range x { + sum += y[i] * v + } + return sum +} + +// DotInc is +// for i := 0; i < int(n); i++ { +// sum += y[iy] * x[ix] +// ix += incX +// iy += incY +// } +// return sum +func DotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float32) { + for i := 0; i < int(n); i++ { + sum += y[iy] * x[ix] + ix += incX + iy += incY + } + return sum +} + +// DdotUnitary is +// for i, v := range x { +// sum += float64(y[i]) * float64(v) +// } +// return +func DdotUnitary(x, y []float32) (sum float64) { + for i, v := range x { + sum += float64(y[i]) * float64(v) + } + return +} + +// DdotInc is +// for i := 0; i < int(n); i++ { +// sum += float64(y[iy]) * float64(x[ix]) +// ix += incX +// iy += incY +// } +// return +func DdotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float64) { + for i := 0; i < int(n); i++ { + sum += float64(y[iy]) * float64(x[ix]) + ix += incX + iy += incY + } + return +} diff --git a/vendor/github.com/gonum/internal/asm/f64/abssum_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/abssum_amd64.s similarity index 97% rename from vendor/github.com/gonum/internal/asm/f64/abssum_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/abssum_amd64.s index 7e7e5d07..1677401a 100644 --- a/vendor/github.com/gonum/internal/asm/f64/abssum_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/abssum_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/abssuminc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/abssuminc_amd64.s similarity index 97% rename from vendor/github.com/gonum/internal/asm/f64/abssuminc_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/abssuminc_amd64.s index f4db05bd..b44ea121 100644 --- a/vendor/github.com/gonum/internal/asm/f64/abssuminc_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/abssuminc_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/add_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/add_amd64.s similarity index 96% rename from vendor/github.com/gonum/internal/asm/f64/add_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/add_amd64.s index 27329699..a8e6818c 100644 --- a/vendor/github.com/gonum/internal/asm/f64/add_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/add_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/addconst_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/addconst_amd64.s similarity index 96% rename from vendor/github.com/gonum/internal/asm/f64/addconst_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/addconst_amd64.s index 88fed071..44b97231 100644 --- a/vendor/github.com/gonum/internal/asm/f64/addconst_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/addconst_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/axpy.go b/vendor/gonum.org/v1/gonum/internal/asm/f64/axpy.go similarity index 95% rename from vendor/github.com/gonum/internal/asm/f64/axpy.go rename to vendor/gonum.org/v1/gonum/internal/asm/f64/axpy.go index 455a5d7e..00b874d1 100644 --- a/vendor/github.com/gonum/internal/asm/f64/axpy.go +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/axpy.go @@ -1,4 +1,4 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/axpyinc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/axpyinc_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f64/axpyinc_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/axpyinc_amd64.s index 214f9704..a8607fe4 100644 --- a/vendor/github.com/gonum/internal/asm/f64/axpyinc_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/axpyinc_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/vendor/github.com/gonum/internal/asm/f64/axpyincto_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/axpyincto_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f64/axpyincto_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/axpyincto_amd64.s index a873b1c9..0fceca6b 100644 --- a/vendor/github.com/gonum/internal/asm/f64/axpyincto_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/axpyincto_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/vendor/github.com/gonum/internal/asm/f64/axpyunitary_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/axpyunitary_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f64/axpyunitary_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/axpyunitary_amd64.s index 668f091e..e37011df 100644 --- a/vendor/github.com/gonum/internal/asm/f64/axpyunitary_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/axpyunitary_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/vendor/github.com/gonum/internal/asm/f64/axpyunitaryto_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/axpyunitaryto_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f64/axpyunitaryto_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/axpyunitaryto_amd64.s index 03132e9d..c9cda0b0 100644 --- a/vendor/github.com/gonum/internal/asm/f64/axpyunitaryto_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/axpyunitaryto_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/vendor/github.com/gonum/internal/asm/f64/cumprod_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/cumprod_amd64.s similarity index 97% rename from vendor/github.com/gonum/internal/asm/f64/cumprod_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/cumprod_amd64.s index 3d438093..a4d34d8b 100644 --- a/vendor/github.com/gonum/internal/asm/f64/cumprod_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/cumprod_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/cumsum_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/cumsum_amd64.s similarity index 96% rename from vendor/github.com/gonum/internal/asm/f64/cumsum_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/cumsum_amd64.s index eecfbbe1..757eccdc 100644 --- a/vendor/github.com/gonum/internal/asm/f64/cumsum_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/cumsum_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/div_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/div_amd64.s similarity index 96% rename from vendor/github.com/gonum/internal/asm/f64/div_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/div_amd64.s index da417708..f3fc1e17 100644 --- a/vendor/github.com/gonum/internal/asm/f64/div_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/div_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/divto_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/divto_amd64.s similarity index 97% rename from vendor/github.com/gonum/internal/asm/f64/divto_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/divto_amd64.s index 6280aab4..e30e8078 100644 --- a/vendor/github.com/gonum/internal/asm/f64/divto_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/divto_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/doc.go b/vendor/gonum.org/v1/gonum/internal/asm/f64/doc.go similarity index 56% rename from vendor/github.com/gonum/internal/asm/f64/doc.go rename to vendor/gonum.org/v1/gonum/internal/asm/f64/doc.go index 7f1cc87c..33c76c1e 100644 --- a/vendor/github.com/gonum/internal/asm/f64/doc.go +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/doc.go @@ -1,6 +1,6 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package f64 provides float64 vector primitives. -package f64 +package f64 // import "gonum.org/v1/gonum/internal/asm/f64" diff --git a/vendor/github.com/gonum/internal/asm/f64/dot.go b/vendor/gonum.org/v1/gonum/internal/asm/f64/dot.go similarity index 91% rename from vendor/github.com/gonum/internal/asm/f64/dot.go rename to vendor/gonum.org/v1/gonum/internal/asm/f64/dot.go index 7b86b5b4..98a17605 100644 --- a/vendor/github.com/gonum/internal/asm/f64/dot.go +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/dot.go @@ -1,4 +1,4 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/dot_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/dot_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f64/dot_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/dot_amd64.s index 02e654d5..79852d1e 100644 --- a/vendor/github.com/gonum/internal/asm/f64/dot_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/dot_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/vendor/github.com/gonum/internal/asm/f64/l1norm_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/l1norm_amd64.s similarity index 96% rename from vendor/github.com/gonum/internal/asm/f64/l1norm_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/l1norm_amd64.s index 2a8c5a38..ae140701 100644 --- a/vendor/github.com/gonum/internal/asm/f64/l1norm_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/l1norm_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/linfnorm_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/linfnorm_amd64.s similarity index 96% rename from vendor/github.com/gonum/internal/asm/f64/linfnorm_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/linfnorm_amd64.s index fb6ef8d2..a6d37461 100644 --- a/vendor/github.com/gonum/internal/asm/f64/linfnorm_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/linfnorm_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/scal.go b/vendor/gonum.org/v1/gonum/internal/asm/f64/scal.go similarity index 94% rename from vendor/github.com/gonum/internal/asm/f64/scal.go rename to vendor/gonum.org/v1/gonum/internal/asm/f64/scal.go index 357e6c4a..9d11a102 100644 --- a/vendor/github.com/gonum/internal/asm/f64/scal.go +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/scal.go @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/scalinc_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/scalinc_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f64/scalinc_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/scalinc_amd64.s index 55a5758e..044d4e93 100644 --- a/vendor/github.com/gonum/internal/asm/f64/scalinc_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/scalinc_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/vendor/github.com/gonum/internal/asm/f64/scalincto_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/scalincto_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f64/scalincto_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/scalincto_amd64.s index 57c90a2a..47e43b1c 100644 --- a/vendor/github.com/gonum/internal/asm/f64/scalincto_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/scalincto_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/vendor/github.com/gonum/internal/asm/f64/scalunitary_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/scalunitary_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f64/scalunitary_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/scalunitary_amd64.s index da23af77..43102f84 100644 --- a/vendor/github.com/gonum/internal/asm/f64/scalunitary_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/scalunitary_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/vendor/github.com/gonum/internal/asm/f64/scalunitaryto_amd64.s b/vendor/gonum.org/v1/gonum/internal/asm/f64/scalunitaryto_amd64.s similarity index 98% rename from vendor/github.com/gonum/internal/asm/f64/scalunitaryto_amd64.s rename to vendor/gonum.org/v1/gonum/internal/asm/f64/scalunitaryto_amd64.s index 3685d5b5..71b5313b 100644 --- a/vendor/github.com/gonum/internal/asm/f64/scalunitaryto_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/scalunitaryto_amd64.s @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // diff --git a/vendor/github.com/gonum/internal/asm/f64/stubs_amd64.go b/vendor/gonum.org/v1/gonum/internal/asm/f64/stubs_amd64.go similarity index 98% rename from vendor/github.com/gonum/internal/asm/f64/stubs_amd64.go rename to vendor/gonum.org/v1/gonum/internal/asm/f64/stubs_amd64.go index d4de1919..f1c532ad 100644 --- a/vendor/github.com/gonum/internal/asm/f64/stubs_amd64.go +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/stubs_amd64.go @@ -1,4 +1,4 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/internal/asm/f64/stubs_noasm.go b/vendor/gonum.org/v1/gonum/internal/asm/f64/stubs_noasm.go similarity index 97% rename from vendor/github.com/gonum/internal/asm/f64/stubs_noasm.go rename to vendor/gonum.org/v1/gonum/internal/asm/f64/stubs_noasm.go index 5e4ae69c..2d0b0ce9 100644 --- a/vendor/github.com/gonum/internal/asm/f64/stubs_noasm.go +++ b/vendor/gonum.org/v1/gonum/internal/asm/f64/stubs_noasm.go @@ -1,4 +1,4 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/gonum.org/v1/gonum/internal/math32/doc.go b/vendor/gonum.org/v1/gonum/internal/math32/doc.go new file mode 100644 index 00000000..68917c64 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/math32/doc.go @@ -0,0 +1,7 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package math32 provides float32 versions of standard library math package +// routines used by gonum/blas/native. +package math32 // import "gonum.org/v1/gonum/internal/math32" diff --git a/vendor/github.com/gonum/blas/native/internal/math32/math.go b/vendor/gonum.org/v1/gonum/internal/math32/math.go similarity index 93% rename from vendor/github.com/gonum/blas/native/internal/math32/math.go rename to vendor/gonum.org/v1/gonum/internal/math32/math.go index b33401b9..56c90be0 100644 --- a/vendor/github.com/gonum/blas/native/internal/math32/math.go +++ b/vendor/gonum.org/v1/gonum/internal/math32/math.go @@ -2,12 +2,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package math32 provides float32 versions of standard library math package -// routines used by gonum/blas/native. package math32 import ( diff --git a/vendor/gonum.org/v1/gonum/internal/math32/signbit.go b/vendor/gonum.org/v1/gonum/internal/math32/signbit.go new file mode 100644 index 00000000..3e9f0bb4 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/internal/math32/signbit.go @@ -0,0 +1,16 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package math32 + +import "math" + +// Signbit returns true if x is negative or negative zero. +func Signbit(x float32) bool { + return math.Float32bits(x)&(1<<31) != 0 +} diff --git a/vendor/github.com/gonum/blas/native/internal/math32/sqrt.go b/vendor/gonum.org/v1/gonum/internal/math32/sqrt.go similarity index 90% rename from vendor/github.com/gonum/blas/native/internal/math32/sqrt.go rename to vendor/gonum.org/v1/gonum/internal/math32/sqrt.go index 5cdde974..ba4747a6 100644 --- a/vendor/github.com/gonum/blas/native/internal/math32/sqrt.go +++ b/vendor/gonum.org/v1/gonum/internal/math32/sqrt.go @@ -1,4 +1,4 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/blas/native/internal/math32/sqrt_amd64.go b/vendor/gonum.org/v1/gonum/internal/math32/sqrt_amd64.go similarity index 88% rename from vendor/github.com/gonum/blas/native/internal/math32/sqrt_amd64.go rename to vendor/gonum.org/v1/gonum/internal/math32/sqrt_amd64.go index 30af43be..48602662 100644 --- a/vendor/github.com/gonum/blas/native/internal/math32/sqrt_amd64.go +++ b/vendor/gonum.org/v1/gonum/internal/math32/sqrt_amd64.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/blas/native/internal/math32/sqrt_amd64.s b/vendor/gonum.org/v1/gonum/internal/math32/sqrt_amd64.s similarity index 90% rename from vendor/github.com/gonum/blas/native/internal/math32/sqrt_amd64.s rename to vendor/gonum.org/v1/gonum/internal/math32/sqrt_amd64.s index 14c66fb9..6df2ce7d 100644 --- a/vendor/github.com/gonum/blas/native/internal/math32/sqrt_amd64.s +++ b/vendor/gonum.org/v1/gonum/internal/math32/sqrt_amd64.s @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/github.com/gonum/lapack/native/dbdsqr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dbdsqr.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dbdsqr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dbdsqr.go index 6a0b0eb8..0b74e567 100644 --- a/vendor/github.com/gonum/lapack/native/dbdsqr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dbdsqr.go @@ -1,15 +1,15 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dbdsqr performs a singular value decomposition of a real n×n bidiagonal matrix. diff --git a/vendor/github.com/gonum/lapack/native/dgebak.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgebak.go similarity index 92% rename from vendor/github.com/gonum/lapack/native/dgebak.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgebak.go index e0edc571..fa9f1eab 100644 --- a/vendor/github.com/gonum/lapack/native/dgebak.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgebak.go @@ -1,12 +1,12 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dgebak updates an n×m matrix V as @@ -28,7 +28,7 @@ func (impl Implementation) Dgebak(job lapack.Job, side lapack.EVSide, n, ilo, ih } switch side { default: - panic(badSide) + panic(badEVSide) case lapack.LeftEV, lapack.RightEV: } checkMatrix(n, m, v, ldv) diff --git a/vendor/github.com/gonum/lapack/native/dgebal.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgebal.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dgebal.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgebal.go index 41ea70fb..4af7eed2 100644 --- a/vendor/github.com/gonum/lapack/native/dgebal.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgebal.go @@ -1,14 +1,14 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dgebal balances an n×n matrix A. Balancing consists of two stages, permuting diff --git a/vendor/github.com/gonum/lapack/native/dgebd2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgebd2.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dgebd2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgebd2.go index c82ba231..a8e4aacb 100644 --- a/vendor/github.com/gonum/lapack/native/dgebd2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgebd2.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dgebd2 reduces an m×n matrix A to upper or lower bidiagonal form by an orthogonal // transformation. diff --git a/vendor/github.com/gonum/lapack/native/dgebrd.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgebrd.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dgebrd.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgebrd.go index 22ca6b38..794ac2c0 100644 --- a/vendor/github.com/gonum/lapack/native/dgebrd.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgebrd.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dgebrd reduces a general m×n matrix A to upper or lower bidiagonal form B by diff --git a/vendor/github.com/gonum/lapack/native/dgecon.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgecon.go similarity index 92% rename from vendor/github.com/gonum/lapack/native/dgecon.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgecon.go index 819490ee..04e01535 100644 --- a/vendor/github.com/gonum/lapack/native/dgecon.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgecon.go @@ -1,15 +1,15 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dgecon estimates the reciprocal of the condition number of the n×n matrix A diff --git a/vendor/github.com/gonum/lapack/native/dgeev.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgeev.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dgeev.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgeev.go index e10a9e36..314074c9 100644 --- a/vendor/github.com/gonum/lapack/native/dgeev.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgeev.go @@ -1,15 +1,15 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dgeev computes the eigenvalues and, optionally, the left and/or right diff --git a/vendor/github.com/gonum/lapack/native/dgehd2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgehd2.go similarity index 96% rename from vendor/github.com/gonum/lapack/native/dgehd2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgehd2.go index 57700797..36828378 100644 --- a/vendor/github.com/gonum/lapack/native/dgehd2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgehd2.go @@ -1,10 +1,10 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dgehd2 reduces a block of a general n×n matrix A to upper Hessenberg form H // by an orthogonal similarity transformation Q^T * A * Q = H. diff --git a/vendor/github.com/gonum/lapack/native/dgehrd.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgehrd.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dgehrd.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgehrd.go index 1bf4680d..027747d1 100644 --- a/vendor/github.com/gonum/lapack/native/dgehrd.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgehrd.go @@ -1,13 +1,13 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dgehrd reduces a block of a real n×n general matrix A to upper Hessenberg diff --git a/vendor/github.com/gonum/lapack/native/dgelq2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgelq2.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dgelq2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgelq2.go index 648be10a..05b3ce45 100644 --- a/vendor/github.com/gonum/lapack/native/dgelq2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgelq2.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dgelq2 computes the LQ factorization of the m×n matrix A. // diff --git a/vendor/github.com/gonum/lapack/native/dgelqf.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgelqf.go similarity index 94% rename from vendor/github.com/gonum/lapack/native/dgelqf.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgelqf.go index 4c124ba5..12913911 100644 --- a/vendor/github.com/gonum/lapack/native/dgelqf.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgelqf.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dgelqf computes the LQ factorization of the m×n matrix A using a blocked diff --git a/vendor/github.com/gonum/lapack/native/dgels.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgels.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dgels.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgels.go index daed361a..214b9663 100644 --- a/vendor/github.com/gonum/lapack/native/dgels.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgels.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dgels finds a minimum-norm solution based on the matrices A and B using the diff --git a/vendor/github.com/gonum/lapack/native/dgeql2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgeql2.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dgeql2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgeql2.go index b5fad21a..6d9b7413 100644 --- a/vendor/github.com/gonum/lapack/native/dgeql2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgeql2.go @@ -1,10 +1,10 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dgeql2 computes the QL factorization of the m×n matrix A. That is, Dgeql2 // computes Q and L such that diff --git a/vendor/github.com/gonum/lapack/native/dgeqp3.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgeqp3.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dgeqp3.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgeqp3.go index a53ca2ca..ef71b3ad 100644 --- a/vendor/github.com/gonum/lapack/native/dgeqp3.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgeqp3.go @@ -1,12 +1,12 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dgeqp3 computes a QR factorization with column pivoting of the diff --git a/vendor/github.com/gonum/lapack/native/dgeqr2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgeqr2.go similarity index 94% rename from vendor/github.com/gonum/lapack/native/dgeqr2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgeqr2.go index 5e8e0f9d..05df4265 100644 --- a/vendor/github.com/gonum/lapack/native/dgeqr2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgeqr2.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dgeqr2 computes a QR factorization of the m×n matrix A. // diff --git a/vendor/github.com/gonum/lapack/native/dgeqrf.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgeqrf.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dgeqrf.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgeqrf.go index 9072c25b..664482cb 100644 --- a/vendor/github.com/gonum/lapack/native/dgeqrf.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgeqrf.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dgeqrf computes the QR factorization of the m×n matrix A using a blocked diff --git a/vendor/github.com/gonum/lapack/native/dgerq2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgerq2.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dgerq2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgerq2.go index b898a2d8..52ac2cb8 100644 --- a/vendor/github.com/gonum/lapack/native/dgerq2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgerq2.go @@ -1,10 +1,10 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dgerq2 computes an RQ factorization of the m×n matrix A, // A = R * Q. diff --git a/vendor/github.com/gonum/lapack/native/dgerqf.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgerqf.go similarity index 96% rename from vendor/github.com/gonum/lapack/native/dgerqf.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgerqf.go index 4530056e..7ecdf55f 100644 --- a/vendor/github.com/gonum/lapack/native/dgerqf.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgerqf.go @@ -1,12 +1,12 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dgerqf computes an RQ factorization of the m×n matrix A, diff --git a/vendor/github.com/gonum/lapack/native/dgesvd.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgesvd.go similarity index 99% rename from vendor/github.com/gonum/lapack/native/dgesvd.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgesvd.go index ccf867bf..70f6db89 100644 --- a/vendor/github.com/gonum/lapack/native/dgesvd.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgesvd.go @@ -1,15 +1,15 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) const noSVDO = "dgesvd: not coded for overwrite" @@ -317,7 +317,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float // Path 10t, n > m impl.Dgebrd(m, n, a, lda, s, nil, nil, nil, work, -1) lwork_dgebrd = int(work[0]) - maxwrk := 3*m + lwork_dgebrd + maxwrk = 3*m + lwork_dgebrd if wantvs || wantvo { impl.Dorgbr(lapack.ApplyP, m, n, m, a, n, nil, work, -1) lwork_dorgbr_p = int(work[0]) diff --git a/vendor/github.com/gonum/lapack/native/dgetf2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgetf2.go similarity index 94% rename from vendor/github.com/gonum/lapack/native/dgetf2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgetf2.go index a7937153..1256bf34 100644 --- a/vendor/github.com/gonum/lapack/native/dgetf2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgetf2.go @@ -1,13 +1,13 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas/blas64" ) // Dgetf2 computes the LU decomposition of the m×n matrix A. diff --git a/vendor/github.com/gonum/lapack/native/dgetrf.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgetrf.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dgetrf.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgetrf.go index d3200b51..7c0cc25b 100644 --- a/vendor/github.com/gonum/lapack/native/dgetrf.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgetrf.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dgetrf computes the LU decomposition of the m×n matrix A. diff --git a/vendor/github.com/gonum/lapack/native/dgetri.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgetri.go similarity index 94% rename from vendor/github.com/gonum/lapack/native/dgetri.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgetri.go index ed0942f3..47f6306e 100644 --- a/vendor/github.com/gonum/lapack/native/dgetri.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgetri.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dgetri computes the inverse of the matrix A using the LU factorization computed diff --git a/vendor/github.com/gonum/lapack/native/dgetrs.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dgetrs.go similarity index 92% rename from vendor/github.com/gonum/lapack/native/dgetrs.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dgetrs.go index 9790d980..da7e0c63 100644 --- a/vendor/github.com/gonum/lapack/native/dgetrs.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dgetrs.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dgetrs solves a system of equations using an LU factorization. diff --git a/vendor/github.com/gonum/lapack/native/dggsvd3.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dggsvd3.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dggsvd3.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dggsvd3.go index 363243ec..be6e8da7 100644 --- a/vendor/github.com/gonum/lapack/native/dggsvd3.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dggsvd3.go @@ -1,14 +1,14 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dggsvd3 computes the generalized singular value decomposition (GSVD) diff --git a/vendor/github.com/gonum/lapack/native/dggsvp3.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dggsvp3.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dggsvp3.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dggsvp3.go index acf06a12..19187968 100644 --- a/vendor/github.com/gonum/lapack/native/dggsvp3.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dggsvp3.go @@ -1,14 +1,14 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dggsvp3 computes orthogonal matrices U, V and Q such that diff --git a/vendor/github.com/gonum/lapack/native/dhseqr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dhseqr.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dhseqr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dhseqr.go index 2b206f11..c9deee90 100644 --- a/vendor/github.com/gonum/lapack/native/dhseqr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dhseqr.go @@ -1,14 +1,14 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dhseqr computes the eigenvalues of an n×n Hessenberg matrix H and, diff --git a/vendor/github.com/gonum/lapack/native/dlabrd.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlabrd.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dlabrd.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlabrd.go index d9a566e5..0527ebef 100644 --- a/vendor/github.com/gonum/lapack/native/dlabrd.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlabrd.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dlabrd reduces the first NB rows and columns of a real general m×n matrix diff --git a/vendor/github.com/gonum/lapack/native/dlacn2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlacn2.go similarity index 96% rename from vendor/github.com/gonum/lapack/native/dlacn2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlacn2.go index fd1e2eb3..751d5caa 100644 --- a/vendor/github.com/gonum/lapack/native/dlacn2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlacn2.go @@ -1,13 +1,13 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas/blas64" ) // Dlacn2 estimates the 1-norm of an n×n matrix A using sequential updates with diff --git a/vendor/github.com/gonum/lapack/native/dlacpy.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlacpy.go similarity index 89% rename from vendor/github.com/gonum/lapack/native/dlacpy.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlacpy.go index e0c7902b..2fe952d5 100644 --- a/vendor/github.com/gonum/lapack/native/dlacpy.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlacpy.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dlacpy copies the elements of A specified by uplo into B. Uplo can specify // a triangular portion with blas.Upper or blas.Lower, or can specify all of the diff --git a/vendor/github.com/gonum/lapack/native/dlae2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlae2.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dlae2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlae2.go index c2fb96ce..c071fec7 100644 --- a/vendor/github.com/gonum/lapack/native/dlae2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlae2.go @@ -1,8 +1,8 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlaev2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaev2.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dlaev2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaev2.go index 7cae50d7..74d75b91 100644 --- a/vendor/github.com/gonum/lapack/native/dlaev2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaev2.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlaexc.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaexc.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dlaexc.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaexc.go index 47a5f810..8ffe2eba 100644 --- a/vendor/github.com/gonum/lapack/native/dlaexc.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaexc.go @@ -1,15 +1,15 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dlaexc swaps two adjacent diagonal blocks of order 1 or 2 in an n×n upper diff --git a/vendor/github.com/gonum/lapack/native/dlags2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlags2.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dlags2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlags2.go index 66fac9b9..6954deb4 100644 --- a/vendor/github.com/gonum/lapack/native/dlags2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlags2.go @@ -1,8 +1,8 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlahqr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlahqr.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dlahqr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlahqr.go index 7e872cc8..66330ab8 100644 --- a/vendor/github.com/gonum/lapack/native/dlahqr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlahqr.go @@ -1,13 +1,13 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas/blas64" ) // Dlahqr computes the eigenvalues and Schur factorization of a block of an n×n @@ -380,7 +380,7 @@ func (impl Implementation) Dlahqr(wantt, wantz bool, n, ilo, ihi int, h []float6 } } - if converged == false { + if !converged { // The QR iteration finished without splitting off a // submatrix of order 1 or 2. return i + 1 diff --git a/vendor/github.com/gonum/lapack/native/dlahr2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlahr2.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dlahr2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlahr2.go index 011f89b6..9d23bc06 100644 --- a/vendor/github.com/gonum/lapack/native/dlahr2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlahr2.go @@ -1,12 +1,12 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dlahr2 reduces the first nb columns of a real general n×(n-k+1) matrix A so diff --git a/vendor/github.com/gonum/lapack/native/dlaln2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaln2.go similarity index 99% rename from vendor/github.com/gonum/lapack/native/dlaln2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaln2.go index 29925cfb..07cf5213 100644 --- a/vendor/github.com/gonum/lapack/native/dlaln2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaln2.go @@ -1,8 +1,8 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlange.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlange.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dlange.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlange.go index 7e65c9e4..76bce5ec 100644 --- a/vendor/github.com/gonum/lapack/native/dlange.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlange.go @@ -1,13 +1,13 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/lapack" ) // Dlange computes the matrix norm of the general m×n matrix a. The input norm diff --git a/vendor/github.com/gonum/lapack/native/dlanst.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlanst.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dlanst.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlanst.go index d806de9b..74eafeb2 100644 --- a/vendor/github.com/gonum/lapack/native/dlanst.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlanst.go @@ -1,13 +1,13 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/lapack" ) // Dlanst computes the specified norm of a symmetric tridiagonal matrix A. diff --git a/vendor/github.com/gonum/lapack/native/dlansy.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlansy.go similarity index 94% rename from vendor/github.com/gonum/lapack/native/dlansy.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlansy.go index 4d610b58..2a380d21 100644 --- a/vendor/github.com/gonum/lapack/native/dlansy.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlansy.go @@ -1,14 +1,14 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dlansy computes the specified norm of an n×n symmetric matrix. If diff --git a/vendor/github.com/gonum/lapack/native/dlantr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlantr.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dlantr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlantr.go index a0fedc46..25702cff 100644 --- a/vendor/github.com/gonum/lapack/native/dlantr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlantr.go @@ -1,14 +1,14 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dlantr computes the specified norm of an m×n trapezoidal matrix A. If diff --git a/vendor/github.com/gonum/lapack/native/dlanv2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlanv2.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dlanv2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlanv2.go index d462f6ed..e5dcfb75 100644 --- a/vendor/github.com/gonum/lapack/native/dlanv2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlanv2.go @@ -1,8 +1,8 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlapll.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlapll.go similarity index 90% rename from vendor/github.com/gonum/lapack/native/dlapll.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlapll.go index eea1827a..cb5c0b7e 100644 --- a/vendor/github.com/gonum/lapack/native/dlapll.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlapll.go @@ -1,10 +1,10 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas/blas64" +import "gonum.org/v1/gonum/blas/blas64" // Dlapll returns the smallest singular value of the n×2 matrix A = [ x y ]. // The function first computes the QR factorization of A = Q*R, and then computes diff --git a/vendor/github.com/gonum/lapack/native/dlapmt.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlapmt.go similarity index 91% rename from vendor/github.com/gonum/lapack/native/dlapmt.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlapmt.go index cb989fea..f5a5b1fd 100644 --- a/vendor/github.com/gonum/lapack/native/dlapmt.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlapmt.go @@ -1,10 +1,10 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas/blas64" +import "gonum.org/v1/gonum/blas/blas64" // Dlapmt rearranges the columns of the m×n matrix X as specified by the // permutation k_0, k_1, ..., k_n-1 of the integers 0, ..., n-1. diff --git a/vendor/github.com/gonum/lapack/native/dlapy2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlapy2.go similarity index 81% rename from vendor/github.com/gonum/lapack/native/dlapy2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlapy2.go index 052a73a9..19f73ffa 100644 --- a/vendor/github.com/gonum/lapack/native/dlapy2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlapy2.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlaqp2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqp2.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dlaqp2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaqp2.go index f9ae6454..80f43905 100644 --- a/vendor/github.com/gonum/lapack/native/dlaqp2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqp2.go @@ -1,14 +1,14 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dlaqp2 computes a QR factorization with column pivoting of the block A[offset:m, 0:n] diff --git a/vendor/github.com/gonum/lapack/native/dlaqps.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqps.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dlaqps.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaqps.go index f96d40a5..89cfd094 100644 --- a/vendor/github.com/gonum/lapack/native/dlaqps.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqps.go @@ -1,14 +1,14 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dlaqps computes a step of QR factorization with column pivoting diff --git a/vendor/github.com/gonum/lapack/native/dlaqr04.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr04.go similarity index 99% rename from vendor/github.com/gonum/lapack/native/dlaqr04.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr04.go index de7e1b46..945c657d 100644 --- a/vendor/github.com/gonum/lapack/native/dlaqr04.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr04.go @@ -1,13 +1,13 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" + "gonum.org/v1/gonum/blas" ) // Dlaqr04 computes the eigenvalues of a block of an n×n upper Hessenberg matrix diff --git a/vendor/github.com/gonum/lapack/native/dlaqr1.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr1.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dlaqr1.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr1.go index 4d482a5d..493b8e44 100644 --- a/vendor/github.com/gonum/lapack/native/dlaqr1.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr1.go @@ -1,8 +1,8 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlaqr23.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr23.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dlaqr23.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr23.go index 0d798dea..24fdf12b 100644 --- a/vendor/github.com/gonum/lapack/native/dlaqr23.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr23.go @@ -1,15 +1,15 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dlaqr23 performs the orthogonal similarity transformation of an n×n upper diff --git a/vendor/github.com/gonum/lapack/native/dlaqr5.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr5.go similarity index 99% rename from vendor/github.com/gonum/lapack/native/dlaqr5.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr5.go index c66516a6..48198122 100644 --- a/vendor/github.com/gonum/lapack/native/dlaqr5.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaqr5.go @@ -1,14 +1,14 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dlaqr5 performs a single small-bulge multi-shift QR sweep on an isolated diff --git a/vendor/github.com/gonum/lapack/native/dlarf.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlarf.go similarity index 94% rename from vendor/github.com/gonum/lapack/native/dlarf.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlarf.go index d51b0149..5fe24f4a 100644 --- a/vendor/github.com/gonum/lapack/native/dlarf.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlarf.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dlarf applies an elementary reflector to a general rectangular matrix c. diff --git a/vendor/github.com/gonum/lapack/native/dlarfb.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlarfb.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dlarfb.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlarfb.go index ed69abe4..3de2684b 100644 --- a/vendor/github.com/gonum/lapack/native/dlarfb.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlarfb.go @@ -1,13 +1,13 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dlarfb applies a block reflector to a matrix. diff --git a/vendor/github.com/gonum/lapack/native/dlarfg.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlarfg.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dlarfg.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlarfg.go index a12735b8..52a67a46 100644 --- a/vendor/github.com/gonum/lapack/native/dlarfg.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlarfg.go @@ -1,13 +1,13 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas/blas64" ) // Dlarfg generates an elementary reflector for a Householder matrix. It creates diff --git a/vendor/github.com/gonum/lapack/native/dlarft.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlarft.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dlarft.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlarft.go index 4a11c62f..eaec8132 100644 --- a/vendor/github.com/gonum/lapack/native/dlarft.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlarft.go @@ -1,13 +1,13 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dlarft forms the triangular factor T of a block reflector H, storing the answer @@ -22,7 +22,7 @@ import ( // and lower triangular otherwise. This function will panic if t is not of // sufficient size. // -// store describes the storage of the elementary reflectors in v. Please see +// store describes the storage of the elementary reflectors in v. See // Dlarfb for a description of layout. // // tau contains the scalar factors of the elementary reflectors H_i. diff --git a/vendor/github.com/gonum/lapack/native/dlarfx.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlarfx.go similarity index 99% rename from vendor/github.com/gonum/lapack/native/dlarfx.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlarfx.go index b730be65..6b3f905c 100644 --- a/vendor/github.com/gonum/lapack/native/dlarfx.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlarfx.go @@ -1,10 +1,10 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dlarfx applies an elementary reflector H to a real m×n matrix C, from either // the left or the right, with loop unrolling when the reflector has order less diff --git a/vendor/github.com/gonum/lapack/native/dlartg.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlartg.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dlartg.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlartg.go index 2b0e324d..ad645461 100644 --- a/vendor/github.com/gonum/lapack/native/dlartg.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlartg.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlas2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlas2.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dlas2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlas2.go index ee37bec1..9922b4aa 100644 --- a/vendor/github.com/gonum/lapack/native/dlas2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlas2.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlascl.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlascl.go similarity index 94% rename from vendor/github.com/gonum/lapack/native/dlascl.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlascl.go index 2c130e8b..51363fe5 100644 --- a/vendor/github.com/gonum/lapack/native/dlascl.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlascl.go @@ -1,13 +1,13 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/lapack" ) // Dlascl multiplies an m×n matrix by the scalar cto/cfrom. diff --git a/vendor/github.com/gonum/lapack/native/dlaset.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaset.go similarity index 90% rename from vendor/github.com/gonum/lapack/native/dlaset.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaset.go index 2781ad56..3116631e 100644 --- a/vendor/github.com/gonum/lapack/native/dlaset.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaset.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dlaset sets the off-diagonal elements of A to alpha, and the diagonal // elements to beta. If uplo == blas.Upper, only the elements in the upper diff --git a/vendor/github.com/gonum/lapack/native/dlasq1.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq1.go similarity index 94% rename from vendor/github.com/gonum/lapack/native/dlasq1.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlasq1.go index d10d3d5c..4a37cfc5 100644 --- a/vendor/github.com/gonum/lapack/native/dlasq1.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq1.go @@ -1,14 +1,14 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dlasq1 computes the singular values of an n×n bidiagonal matrix with diagonal diff --git a/vendor/github.com/gonum/lapack/native/dlasq2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq2.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dlasq2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlasq2.go index 07ee0ecf..009e506b 100644 --- a/vendor/github.com/gonum/lapack/native/dlasq2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq2.go @@ -1,13 +1,13 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/lapack" ) // Dlasq2 computes all the eigenvalues of the symmetric positive @@ -83,7 +83,7 @@ func (impl Implementation) Dlasq2(n int, z []float64) (info int) { // Check for negative data and compute sums of q's and e's. z[2*n-1] = 0 emin := z[1] - var d, e, qmax, zmax float64 + var d, e, qmax float64 var i1, n1 int for k := 0; k < 2*(n-1); k += 2 { if z[k] < 0 || z[k+1] < 0 { @@ -93,14 +93,12 @@ func (impl Implementation) Dlasq2(n int, z []float64) (info int) { e += z[k+1] qmax = math.Max(qmax, z[k]) emin = math.Min(emin, z[k+1]) - zmax = math.Max(math.Max(qmax, zmax), z[k+1]) } if z[2*(n-1)] < 0 { panic("lapack: bad z value") } d += z[2*(n-1)] qmax = math.Max(qmax, z[2*(n-1)]) - zmax = math.Max(qmax, zmax) // Check for diagonality. if e == 0 { for k := 1; k < n; k++ { diff --git a/vendor/github.com/gonum/lapack/native/dlasq3.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq3.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dlasq3.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlasq3.go index 236671f2..7139ebb5 100644 --- a/vendor/github.com/gonum/lapack/native/dlasq3.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq3.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlasq4.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq4.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dlasq4.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlasq4.go index 20aa4612..1d581a20 100644 --- a/vendor/github.com/gonum/lapack/native/dlasq4.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq4.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" @@ -71,7 +71,6 @@ func (impl Implementation) Dlasq4(i0, n0 int, z []float64, pp int, n0in int, dmi np = nn - 9 } else { np = nn - 2*pp - b2 = z[np-2] gam = dn1 if z[np-4] > z[np-2] { return tau, ttype, g diff --git a/vendor/github.com/gonum/lapack/native/dlasq5.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq5.go similarity index 92% rename from vendor/github.com/gonum/lapack/native/dlasq5.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlasq5.go index 3be3fc9b..e9e9fbeb 100644 --- a/vendor/github.com/gonum/lapack/native/dlasq5.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq5.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" @@ -28,7 +28,8 @@ func (impl Implementation) Dlasq5(i0, n0 int, z []float64, pp int, tau, sigma fl emin = z[j4+4] d := z[j4] - tau dmin = d - dmin1 = -z[j4] + // In the reference there are code paths that actually return this value. + // dmin1 = -z[j4] if pp == 0 { for j4loop := 4 * (i0 + 1); j4loop <= 4*((n0+1)-3); j4loop += 4 { j4 := j4loop - 1 @@ -73,7 +74,8 @@ func (impl Implementation) Dlasq5(i0, n0 int, z []float64, pp int, tau, sigma fl emin = z[j4+4] d := z[j4] - tau dmin = d - dmin1 = -z[j4] + // In the reference there are code paths that actually return this value. + // dmin1 = -z[j4] if pp == 0 { for j4loop := 4 * (i0 + 1); j4loop <= 4*((n0+1)-3); j4loop += 4 { j4 := j4loop - 1 diff --git a/vendor/github.com/gonum/lapack/native/dlasq6.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq6.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dlasq6.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlasq6.go index 456b6cae..f12cbf6a 100644 --- a/vendor/github.com/gonum/lapack/native/dlasq6.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasq6.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlasr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasr.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dlasr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlasr.go index 554d5bd6..cc9e3910 100644 --- a/vendor/github.com/gonum/lapack/native/dlasr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasr.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dlasr applies a sequence of plane rotations to the m×n matrix A. This series diff --git a/vendor/github.com/gonum/lapack/native/dlasrt.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasrt.go similarity index 87% rename from vendor/github.com/gonum/lapack/native/dlasrt.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlasrt.go index f471764a..86786cfe 100644 --- a/vendor/github.com/gonum/lapack/native/dlasrt.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasrt.go @@ -1,13 +1,13 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "sort" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/lapack" ) // Dlasrt sorts the numbers in the input slice d. If s == lapack.SortIncreasing, diff --git a/vendor/github.com/gonum/lapack/native/dlassq.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlassq.go similarity index 92% rename from vendor/github.com/gonum/lapack/native/dlassq.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlassq.go index 24f60365..5a7f8709 100644 --- a/vendor/github.com/gonum/lapack/native/dlassq.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlassq.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlasv2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasv2.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dlasv2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlasv2.go index bfae9ecf..204af193 100644 --- a/vendor/github.com/gonum/lapack/native/dlasv2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasv2.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/native/dlaswp.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaswp.go similarity index 91% rename from vendor/github.com/gonum/lapack/native/dlaswp.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlaswp.go index 1eee3057..c5586e05 100644 --- a/vendor/github.com/gonum/lapack/native/dlaswp.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlaswp.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas/blas64" +import "gonum.org/v1/gonum/blas/blas64" // Dlaswp swaps the rows k1 to k2 of a rectangular matrix A according to the // indices in ipiv so that row k is swapped with ipiv[k]. diff --git a/vendor/github.com/gonum/lapack/native/dlasy2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasy2.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dlasy2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlasy2.go index b14cb256..abfe60e5 100644 --- a/vendor/github.com/gonum/lapack/native/dlasy2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlasy2.go @@ -1,13 +1,13 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas/blas64" ) // Dlasy2 solves the Sylvester matrix equation where the matrices are of order 1 diff --git a/vendor/github.com/gonum/lapack/native/dlatrd.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlatrd.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dlatrd.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlatrd.go index 9e47bacc..04eba4a0 100644 --- a/vendor/github.com/gonum/lapack/native/dlatrd.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlatrd.go @@ -1,12 +1,12 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dlatrd reduces nb rows and columns of a real n×n symmetric matrix A to symmetric diff --git a/vendor/github.com/gonum/lapack/native/dlatrs.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dlatrs.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dlatrs.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dlatrs.go index afede760..f0c94764 100644 --- a/vendor/github.com/gonum/lapack/native/dlatrs.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dlatrs.go @@ -1,14 +1,14 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dlatrs solves a triangular system of equations scaled to prevent overflow. It diff --git a/vendor/github.com/gonum/lapack/native/doc.go b/vendor/gonum.org/v1/gonum/lapack/gonum/doc.go similarity index 71% rename from vendor/github.com/gonum/lapack/native/doc.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/doc.go index d622dc50..07156bf1 100644 --- a/vendor/github.com/gonum/lapack/native/doc.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/doc.go @@ -1,22 +1,22 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package native is a pure-go implementation of the LAPACK API. The LAPACK API defines +// Package gonum is a pure-go implementation of the LAPACK API. The LAPACK API defines // a set of algorithms for advanced matrix operations. // // The function definitions and implementations follow that of the netlib reference -// implementation. Please see http://www.netlib.org/lapack/explore-html/ for more +// implementation. See http://www.netlib.org/lapack/explore-html/ for more // information, and http://www.netlib.org/lapack/explore-html/d4/de1/_l_i_c_e_n_s_e_source.html // for more license information. // // Slice function arguments frequently represent vectors and matrices. The data -// layout is identical to that found in https://godoc.org/github.com/gonum/blas/native. +// layout is identical to that found in https://godoc.org/gonum.org/v1/gonum/blas/gonum. // // Most LAPACK functions are built on top the routines defined in the BLAS API, // and as such the computation time for many LAPACK functions is // dominated by BLAS calls. Here, BLAS is accessed through the -// the blas64 package (https://godoc.org/github.com/gonum/blas/blas64). In particular, +// the blas64 package (https://godoc.org/golang.org/v1/gonum/blas/blas64). In particular, // this implies that an external BLAS library will be used if it is // registered in blas64. // @@ -25,4 +25,4 @@ // alone. Future additions will be focused on supporting the gonum matrix // package (https://godoc.org/github.com/gonum/matrix/mat64), though pull requests // with implementations and tests for LAPACK function are encouraged. -package native +package gonum // import "gonum.org/v1/gonum/lapack/gonum" diff --git a/vendor/github.com/gonum/lapack/native/dorg2l.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorg2l.go similarity index 91% rename from vendor/github.com/gonum/lapack/native/dorg2l.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorg2l.go index b51e7f89..32071986 100644 --- a/vendor/github.com/gonum/lapack/native/dorg2l.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorg2l.go @@ -1,12 +1,12 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dorg2l generates an m×n matrix Q with orthonormal columns which is defined diff --git a/vendor/github.com/gonum/lapack/native/dorg2r.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorg2r.go similarity index 91% rename from vendor/github.com/gonum/lapack/native/dorg2r.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorg2r.go index a00c183d..d7525017 100644 --- a/vendor/github.com/gonum/lapack/native/dorg2r.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorg2r.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dorg2r generates an m×n matrix Q with orthonormal columns defined by the diff --git a/vendor/github.com/gonum/lapack/native/dorgbr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorgbr.go similarity index 96% rename from vendor/github.com/gonum/lapack/native/dorgbr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorgbr.go index 2205dda0..c3c4c90a 100644 --- a/vendor/github.com/gonum/lapack/native/dorgbr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorgbr.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/lapack" +import "gonum.org/v1/gonum/lapack" // Dorgbr generates one of the matrices Q or P^T computed by Dgebrd // computed from the decomposition Dgebrd. See Dgebd2 for the description of diff --git a/vendor/github.com/gonum/lapack/native/dorghr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorghr.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dorghr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorghr.go index fb4d57f2..b7ea7b2c 100644 --- a/vendor/github.com/gonum/lapack/native/dorghr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorghr.go @@ -1,8 +1,8 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum // Dorghr generates an n×n orthogonal matrix Q which is defined as the product // of ihi-ilo elementary reflectors: diff --git a/vendor/github.com/gonum/lapack/native/dorgl2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorgl2.go similarity index 90% rename from vendor/github.com/gonum/lapack/native/dorgl2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorgl2.go index b8b26cb7..06303812 100644 --- a/vendor/github.com/gonum/lapack/native/dorgl2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorgl2.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dorgl2 generates an m×n matrix Q with orthonormal rows defined by the diff --git a/vendor/github.com/gonum/lapack/native/dorglq.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorglq.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dorglq.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorglq.go index 732624d1..4f45a6a3 100644 --- a/vendor/github.com/gonum/lapack/native/dorglq.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorglq.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dorglq generates an m×n matrix Q with orthonormal columns defined by the diff --git a/vendor/github.com/gonum/lapack/native/dorgql.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorgql.go similarity index 96% rename from vendor/github.com/gonum/lapack/native/dorgql.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorgql.go index 060d6388..35967d72 100644 --- a/vendor/github.com/gonum/lapack/native/dorgql.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorgql.go @@ -1,12 +1,12 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dorgql generates the m×n matrix Q with orthonormal columns defined as the diff --git a/vendor/github.com/gonum/lapack/native/dorgqr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorgqr.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dorgqr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorgqr.go index 1482190b..6b8fb742 100644 --- a/vendor/github.com/gonum/lapack/native/dorgqr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorgqr.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dorgqr generates an m×n matrix Q with orthonormal columns defined by the diff --git a/vendor/github.com/gonum/lapack/native/dorgtr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorgtr.go similarity index 96% rename from vendor/github.com/gonum/lapack/native/dorgtr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorgtr.go index f025e5bb..6984ff55 100644 --- a/vendor/github.com/gonum/lapack/native/dorgtr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorgtr.go @@ -1,10 +1,10 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dorgtr generates a real orthogonal matrix Q which is defined as the product // of n-1 elementary reflectors of order n as returned by Dsytrd. diff --git a/vendor/github.com/gonum/lapack/native/dorm2r.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorm2r.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dorm2r.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorm2r.go index 8761f4f0..e8fb1d4d 100644 --- a/vendor/github.com/gonum/lapack/native/dorm2r.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorm2r.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dorm2r multiplies a general matrix C by an orthogonal matrix from a QR factorization // determined by Dgeqrf. diff --git a/vendor/github.com/gonum/lapack/native/dormbr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dormbr.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dormbr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dormbr.go index 40a767ab..250d23be 100644 --- a/vendor/github.com/gonum/lapack/native/dormbr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dormbr.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dormbr applies a multiplicative update to the matrix C based on a diff --git a/vendor/github.com/gonum/lapack/native/dormhr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dormhr.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dormhr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dormhr.go index 33593bf4..f6cb1b26 100644 --- a/vendor/github.com/gonum/lapack/native/dormhr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dormhr.go @@ -1,10 +1,10 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dormhr multiplies an m×n general matrix C with an nq×nq orthogonal matrix Q // Q * C, if side == blas.Left and trans == blas.NoTrans, diff --git a/vendor/github.com/gonum/lapack/native/dorml2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dorml2.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dorml2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dorml2.go index 18a2f23c..1c217b5b 100644 --- a/vendor/github.com/gonum/lapack/native/dorml2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dorml2.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dorml2 multiplies a general matrix C by an orthogonal matrix from an LQ factorization // determined by Dgelqf. diff --git a/vendor/github.com/gonum/lapack/native/dormlq.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dormlq.go similarity index 96% rename from vendor/github.com/gonum/lapack/native/dormlq.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dormlq.go index d9cc3ee3..d7a27643 100644 --- a/vendor/github.com/gonum/lapack/native/dormlq.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dormlq.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dormlq multiplies the matrix C by the orthogonal matrix Q defined by the diff --git a/vendor/github.com/gonum/lapack/native/dormqr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dormqr.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dormqr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dormqr.go index 79da3b71..3fa9009f 100644 --- a/vendor/github.com/gonum/lapack/native/dormqr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dormqr.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/lapack" ) // Dormqr multiplies an m×n matrix C by an orthogonal matrix Q as diff --git a/vendor/github.com/gonum/lapack/native/dormr2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dormr2.go similarity index 95% rename from vendor/github.com/gonum/lapack/native/dormr2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dormr2.go index 47c5ed00..3a6b4330 100644 --- a/vendor/github.com/gonum/lapack/native/dormr2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dormr2.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" // Dormr2 multiplies a general matrix C by an orthogonal matrix from a RQ factorization // determined by Dgerqf. diff --git a/vendor/gonum.org/v1/gonum/lapack/gonum/dpbtf2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dpbtf2.go new file mode 100644 index 00000000..0c60385b --- /dev/null +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dpbtf2.go @@ -0,0 +1,97 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gonum + +import ( + "math" + + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" +) + +// Dpbtf2 computes the Cholesky factorization of a symmetric positive banded +// matrix ab. The matrix ab is n×n with kd diagonal bands. The Cholesky +// factorization computed is +// A = U^T * U if ul == blas.Upper +// A = L * L^T if ul == blas.Lower +// ul also specifies the storage of ab. If ul == blas.Upper, then +// ab is stored as an upper-triangular banded matrix with kd super-diagonals, +// and if ul == blas.Lower, ab is stored as a lower-triangular banded matrix +// with kd sub-diagonals. On exit, the banded matrix U or L is stored in-place +// into ab depending on the value of ul. Dpbtf2 returns whether the factorization +// was successfully completed. +// +// The band storage scheme is illustrated below when n = 6, and kd = 2. +// The resulting Cholesky decomposition is stored in the same elements as the +// input band matrix (a11 becomes u11 or l11, etc.). +// +// ul = blas.Upper +// a11 a12 a13 +// a22 a23 a24 +// a33 a34 a35 +// a44 a45 a46 +// a55 a56 * +// a66 * * +// +// ul = blas.Lower +// * * a11 +// * a21 a22 +// a31 a32 a33 +// a42 a43 a44 +// a53 a54 a55 +// a64 a65 a66 +// +// Dpbtf2 is the unblocked version of the algorithm, see Dpbtrf for the blocked +// version. +// +// Dpbtf2 is an internal routine, exported for testing purposes. +func (Implementation) Dpbtf2(ul blas.Uplo, n, kd int, ab []float64, ldab int) (ok bool) { + if ul != blas.Upper && ul != blas.Lower { + panic(badUplo) + } + checkSymBanded(ab, n, kd, ldab) + if n == 0 { + return + } + bi := blas64.Implementation() + kld := max(1, ldab-1) + if ul == blas.Upper { + for j := 0; j < n; j++ { + // Compute U(J,J) and test for non positive-definiteness. + ajj := ab[j*ldab] + if ajj <= 0 { + return false + } + ajj = math.Sqrt(ajj) + ab[j*ldab] = ajj + // Compute elements j+1:j+kn of row J and update the trailing submatrix + // within the band. + kn := min(kd, n-j-1) + if kn > 0 { + bi.Dscal(kn, 1/ajj, ab[j*ldab+1:], 1) + bi.Dsyr(blas.Upper, kn, -1, ab[j*ldab+1:], 1, ab[(j+1)*ldab:], kld) + } + } + return true + } + for j := 0; j < n; j++ { + // Compute L(J,J) and test for non positive-definiteness. + ajj := ab[j*ldab+kd] + if ajj <= 0 { + return false + } + ajj = math.Sqrt(ajj) + ab[j*ldab+kd] = ajj + + // Compute elements J+1:J+KN of column J and update the trailing submatrix + // within the band. + kn := min(kd, n-j-1) + if kn > 0 { + bi.Dscal(kn, 1/ajj, ab[(j+1)*ldab+kd-1:], kld) + bi.Dsyr(blas.Lower, kn, -1, ab[(j+1)*ldab+kd-1:], kld, ab[(j+1)*ldab+kd:], kld) + } + } + return true +} diff --git a/vendor/github.com/gonum/lapack/native/dpocon.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dpocon.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dpocon.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dpocon.go index 2d2304e2..98d6c02b 100644 --- a/vendor/github.com/gonum/lapack/native/dpocon.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dpocon.go @@ -1,14 +1,14 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dpocon estimates the reciprocal of the condition number of a positive-definite diff --git a/vendor/github.com/gonum/lapack/native/dpotf2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dpotf2.go similarity index 92% rename from vendor/github.com/gonum/lapack/native/dpotf2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dpotf2.go index fbb31986..3d1cfb68 100644 --- a/vendor/github.com/gonum/lapack/native/dpotf2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dpotf2.go @@ -1,14 +1,14 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dpotf2 computes the Cholesky decomposition of the symmetric positive definite diff --git a/vendor/github.com/gonum/lapack/native/dpotrf.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dpotrf.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dpotrf.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dpotrf.go index d2adec95..0ff3afcc 100644 --- a/vendor/github.com/gonum/lapack/native/dpotrf.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dpotrf.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dpotrf computes the Cholesky decomposition of the symmetric positive definite diff --git a/vendor/github.com/gonum/lapack/native/drscl.go b/vendor/gonum.org/v1/gonum/lapack/gonum/drscl.go similarity index 89% rename from vendor/github.com/gonum/lapack/native/drscl.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/drscl.go index 88d17374..302c3230 100644 --- a/vendor/github.com/gonum/lapack/native/drscl.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/drscl.go @@ -1,13 +1,13 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas/blas64" ) // Drscl multiplies the vector x by 1/a being careful to avoid overflow or diff --git a/vendor/github.com/gonum/lapack/native/dsteqr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dsteqr.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dsteqr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dsteqr.go index cb9133d0..0e1125e5 100644 --- a/vendor/github.com/gonum/lapack/native/dsteqr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dsteqr.go @@ -1,15 +1,15 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dsteqr computes the eigenvalues and optionally the eigenvectors of a symmetric @@ -98,8 +98,7 @@ func (impl Implementation) Dsteqr(compz lapack.EVComp, n int, d, e, z []float64, type scaletype int const ( - none scaletype = iota - down + down scaletype = iota + 1 up ) var iscale scaletype diff --git a/vendor/github.com/gonum/lapack/native/dsterf.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dsterf.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dsterf.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dsterf.go index 3c9969fc..636cf1eb 100644 --- a/vendor/github.com/gonum/lapack/native/dsterf.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dsterf.go @@ -1,13 +1,13 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/lapack" ) // Dsterf computes all eigenvalues of a symmetric tridiagonal matrix using the diff --git a/vendor/github.com/gonum/lapack/native/dsyev.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dsyev.go similarity index 94% rename from vendor/github.com/gonum/lapack/native/dsyev.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dsyev.go index 032bcbb4..b4c20c75 100644 --- a/vendor/github.com/gonum/lapack/native/dsyev.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dsyev.go @@ -1,15 +1,15 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dsyev computes all eigenvalues and, optionally, the eigenvectors of a real diff --git a/vendor/github.com/gonum/lapack/native/dsytd2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dsytd2.go similarity index 96% rename from vendor/github.com/gonum/lapack/native/dsytd2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dsytd2.go index f0df454e..b6dc60c0 100644 --- a/vendor/github.com/gonum/lapack/native/dsytd2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dsytd2.go @@ -1,12 +1,12 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dsytd2 reduces a symmetric n×n matrix A to symmetric tridiagonal form T by an diff --git a/vendor/github.com/gonum/lapack/native/dsytrd.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dsytrd.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/dsytrd.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dsytrd.go index 4f6f15c9..b079140c 100644 --- a/vendor/github.com/gonum/lapack/native/dsytrd.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dsytrd.go @@ -1,12 +1,12 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dsytrd reduces a symmetric n×n matrix A to symmetric tridiagonal form by an diff --git a/vendor/github.com/gonum/lapack/native/dtgsja.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dtgsja.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dtgsja.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dtgsja.go index a47e2526..8a1beefe 100644 --- a/vendor/github.com/gonum/lapack/native/dtgsja.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dtgsja.go @@ -1,15 +1,15 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dtgsja computes the generalized singular value decomposition (GSVD) diff --git a/vendor/github.com/gonum/lapack/native/dtrcon.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrcon.go similarity index 91% rename from vendor/github.com/gonum/lapack/native/dtrcon.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dtrcon.go index e4e97100..42d9648f 100644 --- a/vendor/github.com/gonum/lapack/native/dtrcon.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrcon.go @@ -1,15 +1,15 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dtrcon estimates the reciprocal of the condition number of a triangular matrix A. diff --git a/vendor/github.com/gonum/lapack/native/dtrevc3.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrevc3.go similarity index 99% rename from vendor/github.com/gonum/lapack/native/dtrevc3.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dtrevc3.go index c0ef920b..200bf17d 100644 --- a/vendor/github.com/gonum/lapack/native/dtrevc3.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrevc3.go @@ -1,15 +1,15 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" ) // Dtrevc3 computes some or all of the right and/or left eigenvectors of an n×n @@ -109,7 +109,7 @@ import ( func (impl Implementation) Dtrevc3(side lapack.EVSide, howmny lapack.HowMany, selected []bool, n int, t []float64, ldt int, vl []float64, ldvl int, vr []float64, ldvr int, mm int, work []float64, lwork int) (m int) { switch side { default: - panic(badSide) + panic(badEVSide) case lapack.RightEV, lapack.LeftEV, lapack.RightLeftEV: } switch howmny { diff --git a/vendor/github.com/gonum/lapack/native/dtrexc.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrexc.go similarity index 98% rename from vendor/github.com/gonum/lapack/native/dtrexc.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dtrexc.go index ec2cec61..40e03785 100644 --- a/vendor/github.com/gonum/lapack/native/dtrexc.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrexc.go @@ -1,10 +1,10 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum -import "github.com/gonum/lapack" +import "gonum.org/v1/gonum/lapack" // Dtrexc reorders the real Schur factorization of a n×n real matrix // A = Q*T*Q^T diff --git a/vendor/github.com/gonum/lapack/native/dtrti2.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrti2.go similarity index 90% rename from vendor/github.com/gonum/lapack/native/dtrti2.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dtrti2.go index 3a258fb9..a43efe6f 100644 --- a/vendor/github.com/gonum/lapack/native/dtrti2.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrti2.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dtrti2 computes the inverse of a triangular matrix, storing the result in place diff --git a/vendor/github.com/gonum/lapack/native/dtrtri.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrtri.go similarity index 93% rename from vendor/github.com/gonum/lapack/native/dtrtri.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dtrtri.go index 700559dd..95f1b3be 100644 --- a/vendor/github.com/gonum/lapack/native/dtrtri.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrtri.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dtrtri computes the inverse of a triangular matrix, storing the result in place diff --git a/vendor/github.com/gonum/lapack/native/dtrtrs.go b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrtrs.go similarity index 84% rename from vendor/github.com/gonum/lapack/native/dtrtrs.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/dtrtrs.go index a9c36419..e1782d23 100644 --- a/vendor/github.com/gonum/lapack/native/dtrtrs.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/dtrtrs.go @@ -1,12 +1,12 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) // Dtrtrs solves a triangular system of the form A * X = B or A^T * X = B. Dtrtrs diff --git a/vendor/github.com/gonum/lapack/native/general.go b/vendor/gonum.org/v1/gonum/lapack/gonum/general.go similarity index 90% rename from vendor/github.com/gonum/lapack/native/general.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/general.go index 0374386e..a82d9969 100644 --- a/vendor/github.com/gonum/lapack/native/general.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/general.go @@ -1,11 +1,11 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import ( - "github.com/gonum/lapack" + "gonum.org/v1/gonum/lapack" ) // Implementation is the native Go implementation of LAPACK routines. It @@ -57,12 +57,10 @@ const ( badVn2 = "lapack: vn2 has insufficient length" badUplo = "lapack: illegal triangle" badWork = "lapack: insufficient working memory" - badWorkStride = "lapack: insufficient working array stride" badZ = "lapack: insufficient z length" kGTM = "lapack: k > m" kGTN = "lapack: k > n" kLT0 = "lapack: k < 0" - mLT0 = "lapack: m < 0" mLTN = "lapack: m < n" nanScale = "lapack: NaN scale factor" negDimension = "lapack: negative matrix dimension" @@ -99,6 +97,21 @@ func checkVector(n int, v []float64, inc int) { } } +func checkSymBanded(ab []float64, n, kd, lda int) { + if n < 0 { + panic("lapack: negative banded length") + } + if kd < 0 { + panic("lapack: negative bandwidth value") + } + if lda < kd+1 { + panic("lapack: stride less than number of bands") + } + if len(ab) < (n-1)*lda+kd { + panic("lapack: insufficient banded vector length") + } +} + func min(a, b int) int { if a < b { return a diff --git a/vendor/github.com/gonum/lapack/native/iladlc.go b/vendor/gonum.org/v1/gonum/lapack/gonum/iladlc.go similarity index 90% rename from vendor/github.com/gonum/lapack/native/iladlc.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/iladlc.go index c7f06489..bd0e4d8f 100644 --- a/vendor/github.com/gonum/lapack/native/iladlc.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/iladlc.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum // Iladlc scans a matrix for its last non-zero column. Returns -1 if the matrix // is all zeros. diff --git a/vendor/github.com/gonum/lapack/native/iladlr.go b/vendor/gonum.org/v1/gonum/lapack/gonum/iladlr.go similarity index 89% rename from vendor/github.com/gonum/lapack/native/iladlr.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/iladlr.go index a488a496..9f9e0d93 100644 --- a/vendor/github.com/gonum/lapack/native/iladlr.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/iladlr.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum // Iladlr scans a matrix for its last non-zero row. Returns -1 if the matrix // is all zeros. diff --git a/vendor/github.com/gonum/lapack/native/ilaenv.go b/vendor/gonum.org/v1/gonum/lapack/gonum/ilaenv.go similarity index 99% rename from vendor/github.com/gonum/lapack/native/ilaenv.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/ilaenv.go index cdd42327..7f08ba60 100644 --- a/vendor/github.com/gonum/lapack/native/ilaenv.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/ilaenv.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum // Ilaenv returns algorithm tuning parameters for the algorithm given by the // input string. ispec specifies the parameter to return: diff --git a/vendor/github.com/gonum/lapack/native/iparmq.go b/vendor/gonum.org/v1/gonum/lapack/gonum/iparmq.go similarity index 97% rename from vendor/github.com/gonum/lapack/native/iparmq.go rename to vendor/gonum.org/v1/gonum/lapack/gonum/iparmq.go index 48cb000f..ea3d6dfb 100644 --- a/vendor/github.com/gonum/lapack/native/iparmq.go +++ b/vendor/gonum.org/v1/gonum/lapack/gonum/iparmq.go @@ -1,8 +1,8 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package native +package gonum import "math" diff --git a/vendor/github.com/gonum/lapack/lapack.go b/vendor/gonum.org/v1/gonum/lapack/lapack.go similarity index 97% rename from vendor/github.com/gonum/lapack/lapack.go rename to vendor/gonum.org/v1/gonum/lapack/lapack.go index 46b493df..1532fce4 100644 --- a/vendor/github.com/gonum/lapack/lapack.go +++ b/vendor/gonum.org/v1/gonum/lapack/lapack.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package lapack +package lapack // import "gonum.org/v1/gonum/lapack" -import "github.com/gonum/blas" +import "gonum.org/v1/gonum/blas" const None = 'N' diff --git a/vendor/gonum.org/v1/gonum/lapack/lapack64/doc.go b/vendor/gonum.org/v1/gonum/lapack/lapack64/doc.go new file mode 100644 index 00000000..da19e3ec --- /dev/null +++ b/vendor/gonum.org/v1/gonum/lapack/lapack64/doc.go @@ -0,0 +1,20 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package lapack64 provides a set of convenient wrapper functions for LAPACK +// calls, as specified in the netlib standard (www.netlib.org). +// +// The native Go routines are used by default, and the Use function can be used +// to set an alternative implementation. +// +// If the type of matrix (General, Symmetric, etc.) is known and fixed, it is +// used in the wrapper signature. In many cases, however, the type of the matrix +// changes during the call to the routine, for example the matrix is symmetric on +// entry and is triangular on exit. In these cases the correct types should be checked +// in the documentation. +// +// The full set of Lapack functions is very large, and it is not clear that a +// full implementation is desirable, let alone feasible. Please open up an issue +// if there is a specific function you need and/or are willing to implement. +package lapack64 // import "gonum.org/v1/gonum/lapack/lapack64" diff --git a/vendor/github.com/gonum/lapack/lapack64/lapack64.go b/vendor/gonum.org/v1/gonum/lapack/lapack64/lapack64.go similarity index 95% rename from vendor/github.com/gonum/lapack/lapack64/lapack64.go rename to vendor/gonum.org/v1/gonum/lapack/lapack64/lapack64.go index 619734fb..259f8cc6 100644 --- a/vendor/github.com/gonum/lapack/lapack64/lapack64.go +++ b/vendor/gonum.org/v1/gonum/lapack/lapack64/lapack64.go @@ -1,32 +1,17 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package lapack64 provides a set of convenient wrapper functions for LAPACK -// calls, as specified in the netlib standard (www.netlib.org). -// -// The native Go routines are used by default, and the Use function can be used -// to set an alternative implementation. -// -// If the type of matrix (General, Symmetric, etc.) is known and fixed, it is -// used in the wrapper signature. In many cases, however, the type of the matrix -// changes during the call to the routine, for example the matrix is symmetric on -// entry and is triangular on exit. In these cases the correct types should be checked -// in the documentation. -// -// The full set of Lapack functions is very large, and it is not clear that a -// full implementation is desirable, let alone feasible. Please open up an issue -// if there is a specific function you need and/or are willing to implement. package lapack64 import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" - "github.com/gonum/lapack/native" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" + "gonum.org/v1/gonum/lapack/gonum" ) -var lapack64 lapack.Float64 = native.Implementation{} +var lapack64 lapack.Float64 = gonum.Implementation{} // Use sets the LAPACK float64 implementation to be used by subsequent BLAS calls. // The default implementation is native.Implementation. diff --git a/vendor/gonum.org/v1/gonum/mat/band.go b/vendor/gonum.org/v1/gonum/mat/band.go new file mode 100644 index 00000000..d196a5ae --- /dev/null +++ b/vendor/gonum.org/v1/gonum/mat/band.go @@ -0,0 +1,228 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mat + +import ( + "gonum.org/v1/gonum/blas/blas64" +) + +var ( + bandDense *BandDense + _ Matrix = bandDense + _ Banded = bandDense + _ RawBander = bandDense + + _ NonZeroDoer = bandDense + _ RowNonZeroDoer = bandDense + _ ColNonZeroDoer = bandDense +) + +// BandDense represents a band matrix in dense storage format. +type BandDense struct { + mat blas64.Band +} + +// Banded is a band matrix representation. +type Banded interface { + Matrix + // Bandwidth returns the lower and upper bandwidth values for + // the matrix. The total bandwidth of the matrix is kl+ku+1. + Bandwidth() (kl, ku int) + + // TBand is the equivalent of the T() method in the Matrix + // interface but guarantees the transpose is of banded type. + TBand() Banded +} + +// A RawBander can return a blas64.Band representation of the receiver. +// Changes to the blas64.Band.Data slice will be reflected in the original +// matrix, changes to the Rows, Cols, KL, KU and Stride fields will not. +type RawBander interface { + RawBand() blas64.Band +} + +// A MutableBanded can set elements of a band matrix. +type MutableBanded interface { + Banded + SetBand(i, j int, v float64) +} + +var ( + _ Matrix = TransposeBand{} + _ Banded = TransposeBand{} + _ UntransposeBander = TransposeBand{} +) + +// TransposeBand is a type for performing an implicit transpose of a band +// matrix. It implements the Banded interface, returning values from the +// transpose of the matrix within. +type TransposeBand struct { + Banded Banded +} + +// At returns the value of the element at row i and column j of the transposed +// matrix, that is, row j and column i of the Banded field. +func (t TransposeBand) At(i, j int) float64 { + return t.Banded.At(j, i) +} + +// Dims returns the dimensions of the transposed matrix. +func (t TransposeBand) Dims() (r, c int) { + c, r = t.Banded.Dims() + return r, c +} + +// T performs an implicit transpose by returning the Banded field. +func (t TransposeBand) T() Matrix { + return t.Banded +} + +// Bandwidth returns the lower and upper bandwidth values for +// the transposed matrix. +func (t TransposeBand) Bandwidth() (kl, ku int) { + kl, ku = t.Banded.Bandwidth() + return ku, kl +} + +// TBand performs an implicit transpose by returning the Banded field. +func (t TransposeBand) TBand() Banded { + return t.Banded +} + +// Untranspose returns the Banded field. +func (t TransposeBand) Untranspose() Matrix { + return t.Banded +} + +// UntransposeBand returns the Banded field. +func (t TransposeBand) UntransposeBand() Banded { + return t.Banded +} + +// NewBandDense creates a new Band matrix with r rows and c columns. If data == nil, +// a new slice is allocated for the backing slice. If len(data) == min(r, c+kl)*(kl+ku+1), +// data is used as the backing slice, and changes to the elements of the returned +// BandDense will be reflected in data. If neither of these is true, NewBandDense +// will panic. kl must be at least zero and less r, and ku must be at least zero and +// less than c, otherwise NewBandDense will panic. +// +// The data must be arranged in row-major order constructed by removing the zeros +// from the rows outside the band and aligning the diagonals. For example, the matrix +// 1 2 3 0 0 0 +// 4 5 6 7 0 0 +// 0 8 9 10 11 0 +// 0 0 12 13 14 15 +// 0 0 0 16 17 18 +// 0 0 0 0 19 20 +// becomes (* entries are never accessed) +// * 1 2 3 +// 4 5 6 7 +// 8 9 10 11 +// 12 13 14 15 +// 16 17 18 * +// 19 20 * * +// which is passed to NewBandDense as []float64{*, 1, 2, 3, 4, ...} with kl=1 and ku=2. +// Only the values in the band portion of the matrix are used. +func NewBandDense(r, c, kl, ku int, data []float64) *BandDense { + if r < 0 || c < 0 || kl < 0 || ku < 0 { + panic("mat: negative dimension") + } + if kl+1 > r || ku+1 > c { + panic("mat: band out of range") + } + bc := kl + ku + 1 + if data != nil && len(data) != min(r, c+kl)*bc { + panic(ErrShape) + } + if data == nil { + data = make([]float64, min(r, c+kl)*bc) + } + return &BandDense{ + mat: blas64.Band{ + Rows: r, + Cols: c, + KL: kl, + KU: ku, + Stride: bc, + Data: data, + }, + } +} + +// NewDiagonalRect is a convenience function that returns a diagonal matrix represented by a +// BandDense. The length of data must be min(r, c) otherwise NewDiagonalRect will panic. +func NewDiagonalRect(r, c int, data []float64) *BandDense { + return NewBandDense(r, c, 0, 0, data) +} + +// Dims returns the number of rows and columns in the matrix. +func (b *BandDense) Dims() (r, c int) { + return b.mat.Rows, b.mat.Cols +} + +// Bandwidth returns the upper and lower bandwidths of the matrix. +func (b *BandDense) Bandwidth() (kl, ku int) { + return b.mat.KL, b.mat.KU +} + +// T performs an implicit transpose by returning the receiver inside a Transpose. +func (b *BandDense) T() Matrix { + return Transpose{b} +} + +// TBand performs an implicit transpose by returning the receiver inside a TransposeBand. +func (b *BandDense) TBand() Banded { + return TransposeBand{b} +} + +// RawBand returns the underlying blas64.Band used by the receiver. +// Changes to elements in the receiver following the call will be reflected +// in returned blas64.Band. +func (b *BandDense) RawBand() blas64.Band { + return b.mat +} + +// DoNonZero calls the function fn for each of the non-zero elements of b. The function fn +// takes a row/column index and the element value of b at (i, j). +func (b *BandDense) DoNonZero(fn func(i, j int, v float64)) { + for i := 0; i < min(b.mat.Rows, b.mat.Cols+b.mat.KL); i++ { + for j := max(0, i-b.mat.KL); j < min(b.mat.Cols, i+b.mat.KU+1); j++ { + v := b.at(i, j) + if v != 0 { + fn(i, j, v) + } + } + } +} + +// DoRowNonZero calls the function fn for each of the non-zero elements of row i of b. The function fn +// takes a row/column index and the element value of b at (i, j). +func (b *BandDense) DoRowNonZero(i int, fn func(i, j int, v float64)) { + if i < 0 || b.mat.Rows <= i { + panic(ErrRowAccess) + } + for j := max(0, i-b.mat.KL); j < min(b.mat.Cols, i+b.mat.KU+1); j++ { + v := b.at(i, j) + if v != 0 { + fn(i, j, v) + } + } +} + +// DoColNonZero calls the function fn for each of the non-zero elements of column j of b. The function fn +// takes a row/column index and the element value of b at (i, j). +func (b *BandDense) DoColNonZero(j int, fn func(i, j int, v float64)) { + if j < 0 || b.mat.Cols <= j { + panic(ErrColAccess) + } + for i := 0; i < min(b.mat.Rows, b.mat.Cols+b.mat.KL); i++ { + if i-b.mat.KL <= j && j < i+b.mat.KU+1 { + v := b.at(i, j) + if v != 0 { + fn(i, j, v) + } + } + } +} diff --git a/vendor/github.com/gonum/matrix/mat64/cholesky.go b/vendor/gonum.org/v1/gonum/mat/cholesky.go similarity index 55% rename from vendor/github.com/gonum/matrix/mat64/cholesky.go rename to vendor/gonum.org/v1/gonum/mat/cholesky.go index 4c3aec64..d95533cf 100644 --- a/vendor/github.com/gonum/matrix/mat64/cholesky.go +++ b/vendor/gonum.org/v1/gonum/mat/cholesky.go @@ -1,21 +1,20 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. +// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack/lapack64" ) const ( - badTriangle = "mat64: invalid triangle" - badCholesky = "mat64: invalid Cholesky factorization" + badTriangle = "mat: invalid triangle" + badCholesky = "mat: invalid Cholesky factorization" ) // Cholesky is a type for creating and using the Cholesky factorization of a @@ -38,39 +37,48 @@ type Cholesky struct { // the norm is estimated from the decomposition. func (c *Cholesky) updateCond(norm float64) { n := c.chol.mat.N - work := make([]float64, 3*n) + work := getFloats(3*n, false) + defer putFloats(work) if norm < 0 { - // This is an approximation. By the definition of a norm, ||AB|| <= ||A|| ||B||. - // Here, A = U^T * U. - // The condition number is ||A|| || A^-1||, so this will underestimate - // the condition number somewhat. - // The norm of the original factorized matrix cannot be stored because of - // update possibilities. - unorm := lapack64.Lantr(matrix.CondNorm, c.chol.mat, work) - lnorm := lapack64.Lantr(matrix.CondNormTrans, c.chol.mat, work) + // This is an approximation. By the definition of a norm, + // |AB| <= |A| |B|. + // Since A = U^T*U, we get for the condition number κ that + // κ(A) := |A| |A^-1| = |U^T*U| |A^-1| <= |U^T| |U| |A^-1|, + // so this will overestimate the condition number somewhat. + // The norm of the original factorized matrix cannot be stored + // because of update possibilities. + unorm := lapack64.Lantr(CondNorm, c.chol.mat, work) + lnorm := lapack64.Lantr(CondNormTrans, c.chol.mat, work) norm = unorm * lnorm } sym := c.chol.asSymBlas() - iwork := make([]int, n) + iwork := getInts(n, false) v := lapack64.Pocon(sym, norm, work, iwork) + putInts(iwork) c.cond = 1 / v } +// Cond returns the condition number of the factorized matrix. +func (c *Cholesky) Cond() float64 { + return c.cond +} + // Factorize calculates the Cholesky decomposition of the matrix A and returns // whether the matrix is positive definite. If Factorize returns false, the // factorization must not be used. func (c *Cholesky) Factorize(a Symmetric) (ok bool) { n := a.Symmetric() - if c.isZero() { - c.chol = NewTriDense(n, matrix.Upper, nil) + if c.chol == nil { + c.chol = NewTriDense(n, Upper, nil) } else { - c.chol = NewTriDense(n, matrix.Upper, use(c.chol.mat.Data, n*n)) + c.chol = NewTriDense(n, Upper, use(c.chol.mat.Data, n*n)) } copySymIntoTriangle(c.chol, a) sym := c.chol.asSymBlas() - work := make([]float64, c.chol.mat.N) - norm := lapack64.Lansy(matrix.CondNorm, sym, work) + work := getFloats(c.chol.mat.N, false) + norm := lapack64.Lansy(CondNorm, sym, work) + putFloats(work) _, ok = lapack64.Potrf(sym) if ok { c.updateCond(norm) @@ -83,7 +91,7 @@ func (c *Cholesky) Factorize(a Symmetric) (ok bool) { // Reset resets the factorization so that it can be reused as the receiver of a // dimensionally restricted operation. func (c *Cholesky) Reset() { - if !c.isZero() { + if c.chol != nil { c.chol.Reset() } c.cond = math.Inf(1) @@ -94,13 +102,13 @@ func (c *Cholesky) Reset() { // not stored inside, the receiver. func (c *Cholesky) SetFromU(t *TriDense) { n, kind := t.Triangle() - if kind != matrix.Upper { + if kind != Upper { panic("cholesky: matrix must be upper triangular") } - if c.isZero() { - c.chol = NewTriDense(n, matrix.Upper, nil) + if c.chol == nil { + c.chol = NewTriDense(n, Upper, nil) } else { - c.chol = NewTriDense(n, matrix.Upper, use(c.chol.mat.Data, n*n)) + c.chol = NewTriDense(n, Upper, use(c.chol.mat.Data, n*n)) } c.chol.Copy(t) c.updateCond(-1) @@ -114,10 +122,10 @@ func (c *Cholesky) Clone(chol *Cholesky) { panic(badCholesky) } n := chol.Size() - if c.isZero() { - c.chol = NewTriDense(n, matrix.Upper, nil) + if c.chol == nil { + c.chol = NewTriDense(n, Upper, nil) } else { - c.chol = NewTriDense(n, matrix.Upper, use(c.chol.mat.Data, n*n)) + c.chol = NewTriDense(n, Upper, use(c.chol.mat.Data, n*n)) } c.chol.Copy(chol.chol) c.cond = chol.cond @@ -151,40 +159,39 @@ func (c *Cholesky) LogDet() float64 { return det } -// SolveCholesky finds the matrix m that solves A * m = b where A is represented -// by the Cholesky decomposition, placing the result in the receiver. -func (m *Dense) SolveCholesky(chol *Cholesky, b Matrix) error { - if !chol.valid() { +// Solve finds the matrix m that solves A * m = b where A is represented +// by the Cholesky decomposition, placing the result in m. +func (c *Cholesky) Solve(m *Dense, b Matrix) error { + if !c.valid() { panic(badCholesky) } - n := chol.chol.mat.N + n := c.chol.mat.N bm, bn := b.Dims() if n != bm { - panic(matrix.ErrShape) + panic(ErrShape) } m.reuseAs(bm, bn) if b != m { m.Copy(b) } - blas64.Trsm(blas.Left, blas.Trans, 1, chol.chol.mat, m.mat) - blas64.Trsm(blas.Left, blas.NoTrans, 1, chol.chol.mat, m.mat) - if chol.cond > matrix.ConditionTolerance { - return matrix.Condition(chol.cond) + blas64.Trsm(blas.Left, blas.Trans, 1, c.chol.mat, m.mat) + blas64.Trsm(blas.Left, blas.NoTrans, 1, c.chol.mat, m.mat) + if c.cond > ConditionTolerance { + return Condition(c.cond) } return nil } -// TODO(kortschak): Export this as SolveTwoChol. -// solveTwoChol finds the matrix m that solves A * m = B where A and B are represented +// SolveChol finds the matrix m that solves A * m = B where A and B are represented // by their Cholesky decompositions a and b, placing the result in the receiver. -func (m *Dense) solveTwoChol(a, b *Cholesky) error { +func (a *Cholesky) SolveChol(m *Dense, b *Cholesky) error { if !a.valid() || !b.valid() { panic(badCholesky) } bn := b.chol.mat.N if a.chol.mat.N != bn { - panic(matrix.ErrShape) + panic(ErrShape) } m.reuseAsZeroed(bn, bn) @@ -192,99 +199,218 @@ func (m *Dense) solveTwoChol(a, b *Cholesky) error { blas64.Trsm(blas.Left, blas.Trans, 1, a.chol.mat, m.mat) blas64.Trsm(blas.Left, blas.NoTrans, 1, a.chol.mat, m.mat) blas64.Trmm(blas.Right, blas.NoTrans, 1, b.chol.mat, m.mat) - if a.cond > matrix.ConditionTolerance { - return matrix.Condition(a.cond) + if a.cond > ConditionTolerance { + return Condition(a.cond) } return nil } -// SolveCholeskyVec finds the vector v that solves A * v = b where A is represented -// by the Cholesky decomposition, placing the result in the receiver. -func (v *Vector) SolveCholeskyVec(chol *Cholesky, b *Vector) error { - if !chol.valid() { +// SolveVec finds the vector v that solves A * v = b where A is represented +// by the Cholesky decomposition, placing the result in v. +func (c *Cholesky) SolveVec(v *VecDense, b Vector) error { + if !c.valid() { panic(badCholesky) } - n := chol.chol.mat.N - vn := b.Len() - if vn != n { - panic(matrix.ErrShape) + n := c.chol.mat.N + if br, bc := b.Dims(); br != n || bc != 1 { + panic(ErrShape) } - if v != b { - v.checkOverlap(b.mat) + switch rv := b.(type) { + default: + v.reuseAs(n) + return c.Solve(v.asDense(), b) + case RawVectorer: + bmat := rv.RawVector() + if v != b { + v.checkOverlap(bmat) + } + v.reuseAs(n) + if v != b { + v.CopyVec(b) + } + blas64.Trsv(blas.Trans, c.chol.mat, v.mat) + blas64.Trsv(blas.NoTrans, c.chol.mat, v.mat) + if c.cond > ConditionTolerance { + return Condition(c.cond) + } + return nil } - v.reuseAs(n) - if v != b { - v.CopyVec(b) - } - blas64.Trsv(blas.Trans, chol.chol.mat, v.mat) - blas64.Trsv(blas.NoTrans, chol.chol.mat, v.mat) - if chol.cond > matrix.ConditionTolerance { - return matrix.Condition(chol.cond) - } - return nil - } -// UFromCholesky extracts the n×n upper triangular matrix U from a Cholesky -// decomposition +// RawU returns the Triangular matrix used to store the Cholesky decomposition of +// the original matrix A. The returned matrix should not be modified. If it is +// modified, the decomposition is invalid and should not be used. +func (c *Cholesky) RawU() Triangular { + return c.chol +} + +// UTo extracts the n×n upper triangular matrix U from a Cholesky +// decomposition into dst and returns the result. If dst is nil a new +// TriDense is allocated. // A = U^T * U. -func (t *TriDense) UFromCholesky(chol *Cholesky) { - if !chol.valid() { +func (c *Cholesky) UTo(dst *TriDense) *TriDense { + if !c.valid() { panic(badCholesky) } - n := chol.chol.mat.N - t.reuseAs(n, matrix.Upper) - t.Copy(chol.chol) + n := c.chol.mat.N + if dst == nil { + dst = NewTriDense(n, Upper, make([]float64, n*n)) + } else { + dst.reuseAs(n, Upper) + } + dst.Copy(c.chol) + return dst } -// LFromCholesky extracts the n×n lower triangular matrix L from a Cholesky -// decomposition +// LTo extracts the n×n lower triangular matrix L from a Cholesky +// decomposition into dst and returns the result. If dst is nil a new +// TriDense is allocated. // A = L * L^T. -func (t *TriDense) LFromCholesky(chol *Cholesky) { - if !chol.valid() { +func (c *Cholesky) LTo(dst *TriDense) *TriDense { + if !c.valid() { panic(badCholesky) } - n := chol.chol.mat.N - t.reuseAs(n, matrix.Lower) - t.Copy(chol.chol.TTri()) + n := c.chol.mat.N + if dst == nil { + dst = NewTriDense(n, Lower, make([]float64, n*n)) + } else { + dst.reuseAs(n, Lower) + } + dst.Copy(c.chol.TTri()) + return dst } -// FromCholesky reconstructs the original positive definite matrix given its -// Cholesky decomposition. -func (s *SymDense) FromCholesky(chol *Cholesky) { - if !chol.valid() { +// ToSym reconstructs the original positive definite matrix given its +// Cholesky decomposition into dst and returns the result. If dst is nil +// a new SymDense is allocated. +func (c *Cholesky) ToSym(dst *SymDense) *SymDense { + if !c.valid() { panic(badCholesky) } - n := chol.chol.mat.N - s.reuseAs(n) - s.SymOuterK(1, chol.chol.T()) + n := c.chol.mat.N + if dst == nil { + dst = NewSymDense(n, make([]float64, n*n)) + } else { + dst.reuseAs(n) + } + dst.SymOuterK(1, c.chol.T()) + return dst } -// InverseCholesky computes the inverse of the matrix represented by its Cholesky -// factorization and stores the result into the receiver. If the factorized +// InverseTo computes the inverse of the matrix represented by its Cholesky +// factorization and stores the result into s. If the factorized // matrix is ill-conditioned, a Condition error will be returned. // Note that matrix inversion is numerically unstable, and should generally be // avoided where possible, for example by using the Solve routines. -func (s *SymDense) InverseCholesky(chol *Cholesky) error { - if !chol.valid() { +func (c *Cholesky) InverseTo(s *SymDense) error { + if !c.valid() { panic(badCholesky) } // TODO(btracey): Replace this code with a direct call to Dpotri when it // is available. - s.reuseAs(chol.chol.mat.N) + s.reuseAs(c.chol.mat.N) // If: // chol(A) = U^T * U // Then: // chol(A^-1) = S * S^T // where S = U^-1 var t TriDense - err := t.InverseTri(chol.chol) + err := t.InverseTri(c.chol) s.SymOuterK(1, &t) return err } +// Scale multiplies the original matrix A by a positive constant using +// its Cholesky decomposition, storing the result in-place into the receiver. +// That is, if the original Cholesky factorization is +// U^T * U = A +// the updated factorization is +// U'^T * U' = f A = A' +// Scale panics if the constant is non-positive, or if the receiver is non-zero +// and is of a different Size from the input. +func (c *Cholesky) Scale(f float64, orig *Cholesky) { + if !orig.valid() { + panic(badCholesky) + } + if f <= 0 { + panic("cholesky: scaling by a non-positive constant") + } + n := orig.Size() + if c.chol == nil { + c.chol = NewTriDense(n, Upper, nil) + } else if c.chol.mat.N != n { + panic(ErrShape) + } + c.chol.ScaleTri(math.Sqrt(f), orig.chol) + c.cond = orig.cond // Scaling by a positive constant does not change the condition number. +} + +// ExtendVecSym computes the Cholesky decomposition of the original matrix A, +// whose Cholesky decomposition is in a, extended by a the n×1 vector v according to +// [A w] +// [w' k] +// where k = v[n-1] and w = v[:n-1]. The result is stored into the receiver. +// In order for the updated matrix to be positive definite, it must be the case +// that k > w' A^-1 w. If this condition does not hold then ExtendVecSym will +// return false and the receiver will not be updated. +// +// ExtendVecSym will panic if v.Len() != a.Size()+1 or if a does not contain +// a valid decomposition. +func (chol *Cholesky) ExtendVecSym(a *Cholesky, v Vector) (ok bool) { + n := a.Size() + if v.Len() != n+1 { + panic(badSliceLength) + } + if !a.valid() { + panic(badCholesky) + } + + // The algorithm is commented here, but see also + // https://math.stackexchange.com/questions/955874/cholesky-factor-when-adding-a-row-and-column-to-already-factorized-matrix + // We have A and want to compute the Cholesky of + // [A w] + // [w' k] + // We want + // [U c] + // [0 d] + // to be the updated Cholesky, and so it must be that + // [A w] = [U' 0] [U c] + // [w' k] [c' d] [0 d] + // Thus, we need + // 1) A = U'U (true by the original decomposition being valid), + // 2) U' * c = w => c = U'^-1 w + // 3) c'*c + d'*d = k => d = sqrt(k-c'*c) + + // First, compute c = U'^-1 a + // TODO(btracey): Replace this with CopyVec when issue 167 is fixed. + w := NewVecDense(n, nil) + for i := 0; i < n; i++ { + w.SetVec(i, v.At(i, 0)) + } + k := v.At(n, 0) + + c := NewVecDense(n, nil) + c.SolveVec(a.chol.T(), w) + + dot := Dot(c, c) + if dot >= k { + return false + } + d := math.Sqrt(k - dot) + + newU := NewTriDense(n+1, Upper, nil) + newU.Copy(a.chol) + for i := 0; i < n; i++ { + newU.SetTri(i, n, c.At(i, 0)) + } + newU.SetTri(n, n, d) + chol.chol = newU + chol.updateCond(-1) + return true +} + // SymRankOne performs a rank-1 update of the original matrix A and refactorizes -// its Cholesky factorization, storing the result into the reciever. That is, if +// its Cholesky factorization, storing the result into the receiver. That is, if // in the original Cholesky factorization // U^T * U = A, // in the updated factorization @@ -297,19 +423,19 @@ func (s *SymDense) InverseCholesky(chol *Cholesky) error { // // SymRankOne updates a Cholesky factorization in O(n²) time. The Cholesky // factorization computation from scratch is O(n³). -func (c *Cholesky) SymRankOne(orig *Cholesky, alpha float64, x *Vector) (ok bool) { +func (c *Cholesky) SymRankOne(orig *Cholesky, alpha float64, x *VecDense) (ok bool) { if !orig.valid() { panic(badCholesky) } n := orig.Size() if x.Len() != n { - panic(matrix.ErrShape) + panic(ErrShape) } if orig != c { - if c.isZero() { - c.chol = NewTriDense(n, matrix.Upper, nil) + if c.chol == nil { + c.chol = NewTriDense(n, Upper, nil) } else if c.chol.mat.N != n { - panic(matrix.ErrShape) + panic(ErrShape) } c.chol.Copy(orig.chol) } @@ -344,7 +470,8 @@ func (c *Cholesky) SymRankOne(orig *Cholesky, alpha float64, x *Vector) (ok bool // EPFL Technical Report 161468 (2004) // http://infoscience.epfl.ch/record/161468 - work := make([]float64, n) + work := getFloats(n, false) + defer putFloats(work) blas64.Copy(n, x.RawVector(), blas64.Vector{1, work}) if alpha > 0 { @@ -403,8 +530,10 @@ func (c *Cholesky) SymRankOne(orig *Cholesky, alpha float64, x *Vector) (ok bool return false } norm = math.Sqrt((1 + norm) * (1 - norm)) - cos := make([]float64, n) - sin := make([]float64, n) + cos := getFloats(n, false) + defer putFloats(cos) + sin := getFloats(n, false) + defer putFloats(sin) for i := n - 1; i >= 0; i-- { // Compute parameters of Givens matrices that zero elements of p // backwards. @@ -442,10 +571,6 @@ func (c *Cholesky) SymRankOne(orig *Cholesky, alpha float64, x *Vector) (ok bool return ok } -func (c *Cholesky) isZero() bool { - return c.chol == nil -} - func (c *Cholesky) valid() bool { - return !c.isZero() && !c.chol.isZero() + return c.chol != nil && !c.chol.IsZero() } diff --git a/vendor/gonum.org/v1/gonum/mat/cmatrix.go b/vendor/gonum.org/v1/gonum/mat/cmatrix.go new file mode 100644 index 00000000..fa8e135b --- /dev/null +++ b/vendor/gonum.org/v1/gonum/mat/cmatrix.go @@ -0,0 +1,71 @@ +// Copyright ©2013 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mat + +// CMatrix is the basic matrix interface type for complex matrices. +type CMatrix interface { + // Dims returns the dimensions of a Matrix. + Dims() (r, c int) + + // At returns the value of a matrix element at row i, column j. + // It will panic if i or j are out of bounds for the matrix. + At(i, j int) complex128 + + // H returns the conjugate transpose of the Matrix. Whether H + // returns a copy of the underlying data is implementation dependent. + // This method may be implemented using the Conjugate type, which + // provides an implicit matrix conjugate transpose. + H() CMatrix +} + +var ( + _ CMatrix = Conjugate{} + _ Unconjugator = Conjugate{} +) + +// Conjugate is a type for performing an implicit matrix conjugate transpose. +// It implements the Matrix interface, returning values from the conjugate +// transpose of the matrix within. +type Conjugate struct { + CMatrix CMatrix +} + +// At returns the value of the element at row i and column j of the transposed +// matrix, that is, row j and column i of the Matrix field. +func (t Conjugate) At(i, j int) complex128 { + z := t.CMatrix.At(j, i) + return complex(real(z), -imag(z)) +} + +// Dims returns the dimensions of the transposed matrix. The number of rows returned +// is the number of columns in the Matrix field, and the number of columns is +// the number of rows in the Matrix field. +func (t Conjugate) Dims() (r, c int) { + c, r = t.CMatrix.Dims() + return r, c +} + +// H performs an implicit conjugate transpose by returning the Matrix field. +func (t Conjugate) H() CMatrix { + return t.CMatrix +} + +// Unconjugate returns the Matrix field. +func (t Conjugate) Unconjugate() CMatrix { + return t.CMatrix +} + +// Unconjugator is a type that can undo an implicit conjugate transpose. +type Unconjugator interface { + // Note: This interface is needed to unify all of the Conjugate types. In + // the cmat128 methods, we need to test if the Matrix has been implicitly + // transposed. If this is checked by testing for the specific Conjugate type + // then the behavior will be different if the user uses H() or HTri() for a + // triangular matrix. + + // Unconjugate returns the underlying Matrix stored for the implicit + // conjugate transpose. + Unconjugate() CMatrix +} diff --git a/vendor/github.com/gonum/matrix/consts.go b/vendor/gonum.org/v1/gonum/mat/consts.go similarity index 95% rename from vendor/github.com/gonum/matrix/consts.go rename to vendor/gonum.org/v1/gonum/mat/consts.go index b288b272..a7b6370d 100644 --- a/vendor/github.com/gonum/matrix/consts.go +++ b/vendor/gonum.org/v1/gonum/mat/consts.go @@ -1,8 +1,8 @@ -// Copyright ©2016 The gonum Authors. All rights reserved. +// Copyright ©2016 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package matrix +package mat // TriKind represents the triangularity of the matrix. type TriKind bool diff --git a/vendor/github.com/gonum/matrix/mat64/dense.go b/vendor/gonum.org/v1/gonum/mat/dense.go similarity index 87% rename from vendor/github.com/gonum/matrix/mat64/dense.go rename to vendor/gonum.org/v1/gonum/mat/dense.go index c1bea062..819a9c3b 100644 --- a/vendor/github.com/gonum/matrix/mat64/dense.go +++ b/vendor/gonum.org/v1/gonum/mat/dense.go @@ -1,13 +1,12 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. +// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) var ( @@ -17,7 +16,6 @@ var ( _ Mutable = dense _ Cloner = dense - _ Viewer = dense _ RowViewer = dense _ ColViewer = dense _ RawRowViewer = dense @@ -45,7 +43,7 @@ type Dense struct { // element in the data slice is the {i, j}-th element in the matrix. func NewDense(r, c int, data []float64) *Dense { if data != nil && r*c != len(data) { - panic(matrix.ErrShape) + panic(ErrShape) } if data == nil { data = make([]float64, r*c) @@ -68,10 +66,10 @@ func NewDense(r, c int, data []float64) *Dense { // reuseAs must be kept in sync with reuseAsZeroed. func (m *Dense) reuseAs(r, c int) { if m.mat.Rows > m.capRows || m.mat.Cols > m.capCols { - // Panic as a string, not a mat64.Error. - panic("mat64: caps not correctly set") + // Panic as a string, not a mat.Error. + panic("mat: caps not correctly set") } - if m.isZero() { + if m.IsZero() { m.mat = blas64.General{ Rows: r, Cols: c, @@ -83,7 +81,7 @@ func (m *Dense) reuseAs(r, c int) { return } if r != m.mat.Rows || c != m.mat.Cols { - panic(matrix.ErrShape) + panic(ErrShape) } } @@ -94,10 +92,10 @@ func (m *Dense) reuseAs(r, c int) { // reuseAsZeroed must be kept in sync with reuseAs. func (m *Dense) reuseAsZeroed(r, c int) { if m.mat.Rows > m.capRows || m.mat.Cols > m.capCols { - // Panic as a string, not a mat64.Error. - panic("mat64: caps not correctly set") + // Panic as a string, not a mat.Error. + panic("mat: caps not correctly set") } - if m.isZero() { + if m.IsZero() { m.mat = blas64.General{ Rows: r, Cols: c, @@ -109,7 +107,7 @@ func (m *Dense) reuseAsZeroed(r, c int) { return } if r != m.mat.Rows || c != m.mat.Cols { - panic(matrix.ErrShape) + panic(ErrShape) } for i := 0; i < r; i++ { zero(m.mat.Data[i*m.mat.Stride : i*m.mat.Stride+c]) @@ -149,7 +147,9 @@ func (m *Dense) Reset() { m.mat.Data = m.mat.Data[:0] } -func (m *Dense) isZero() bool { +// IsZero returns whether the receiver is zero-sized. Zero-sized matrices can be the +// receiver for size-restricted operations. Dense matrices can be zeroed using Reset. +func (m *Dense) IsZero() bool { // It must be the case that m.Dims() returns // zeros in this case. See comment in Reset(). return m.mat.Stride == 0 @@ -204,27 +204,20 @@ func (m *Dense) T() Matrix { // ColView returns a Vector reflecting the column j, backed by the matrix data. // // See ColViewer for more information. -func (m *Dense) ColView(j int) *Vector { - if j >= m.mat.Cols || j < 0 { - panic(matrix.ErrColAccess) - } - return &Vector{ - mat: blas64.Vector{ - Inc: m.mat.Stride, - Data: m.mat.Data[j : (m.mat.Rows-1)*m.mat.Stride+j+1], - }, - n: m.mat.Rows, - } +func (m *Dense) ColView(j int) Vector { + var v VecDense + v.ColViewOf(m, j) + return &v } // SetCol sets the values in the specified column of the matrix to the values // in src. len(src) must equal the number of rows in the receiver. func (m *Dense) SetCol(j int, src []float64) { if j >= m.mat.Cols || j < 0 { - panic(matrix.ErrColAccess) + panic(ErrColAccess) } if len(src) != m.mat.Rows { - panic(matrix.ErrColLength) + panic(ErrColLength) } blas64.Copy(m.mat.Rows, @@ -237,10 +230,10 @@ func (m *Dense) SetCol(j int, src []float64) { // in src. len(src) must equal the number of columns in the receiver. func (m *Dense) SetRow(i int, src []float64) { if i >= m.mat.Rows || i < 0 { - panic(matrix.ErrRowAccess) + panic(ErrRowAccess) } if len(src) != m.mat.Cols { - panic(matrix.ErrRowLength) + panic(ErrRowLength) } copy(m.rawRowView(i), src) @@ -250,24 +243,17 @@ func (m *Dense) SetRow(i int, src []float64) { // backed by the matrix data. // // See RowViewer for more information. -func (m *Dense) RowView(i int) *Vector { - if i >= m.mat.Rows || i < 0 { - panic(matrix.ErrRowAccess) - } - return &Vector{ - mat: blas64.Vector{ - Inc: 1, - Data: m.rawRowView(i), - }, - n: m.mat.Cols, - } +func (m *Dense) RowView(i int) Vector { + var v VecDense + v.RowViewOf(m, i) + return &v } // RawRowView returns a slice backed by the same array as backing the // receiver. func (m *Dense) RawRowView(i int) []float64 { if i >= m.mat.Rows || i < 0 { - panic(matrix.ErrRowAccess) + panic(ErrRowAccess) } return m.rawRowView(i) } @@ -276,25 +262,16 @@ func (m *Dense) rawRowView(i int) []float64 { return m.mat.Data[i*m.mat.Stride : i*m.mat.Stride+m.mat.Cols] } -// View returns a new Matrix that shares backing data with the receiver. -// The new matrix is located from row i, column j extending r rows and c -// columns. View panics if the view is outside the bounds of the receiver. -// -// View is deprecated and should not be used. It will be removed at a later date. -func (m *Dense) View(i, j, r, c int) Matrix { - return m.Slice(i, i+r, j, j+c) -} - // Slice returns a new Matrix that shares backing data with the receiver. -// The returned matrix starts at {i,j} of the recevier and extends k-i rows +// The returned matrix starts at {i,j} of the receiver and extends k-i rows // and l-j columns. The final row in the resulting matrix is k-1 and the // final column is l-1. -// Slice panics with ErrIndexOutOfRange if the slice is outside the bounds +// Slice panics with ErrIndexOutOfRange if the slice is outside the capacity // of the receiver. func (m *Dense) Slice(i, k, j, l int) Matrix { - mr, mc := m.Dims() + mr, mc := m.Caps() if i < 0 || mr <= i || j < 0 || mc <= j || k <= i || mr < k || l <= j || mc < l { - panic(matrix.ErrIndexOutOfRange) + panic(ErrIndexOutOfRange) } t := *m t.mat.Data = t.mat.Data[i*t.mat.Stride+j : (k-1)*t.mat.Stride+l] @@ -311,7 +288,7 @@ func (m *Dense) Slice(i, k, j, l int) Matrix { // during the call to Grow. func (m *Dense) Grow(r, c int) Matrix { if r < 0 || c < 0 { - panic(matrix.ErrIndexOutOfRange) + panic(ErrIndexOutOfRange) } if r == 0 && c == 0 { return m @@ -400,7 +377,7 @@ func (m *Dense) Clone(a Matrix) { copy(mat.Data[i*c:(i+1)*c], amat.Data[i*amat.Stride:i*amat.Stride+c]) } } - case *Vector: + case *VecDense: amat := aU.mat mat.Data = make([]float64, aU.n) blas64.Copy(aU.n, @@ -424,7 +401,7 @@ func (m *Dense) Clone(a Matrix) { // Copy makes a copy of elements of a into the receiver. It is similar to the // built-in copy; it copies as much as the overlap between the two matrices and // returns the number of rows and columns it copied. If a aliases the receiver -// and is a transposed Dense or Vector, with a non-unitary increment, Copy will +// and is a transposed Dense or VecDense, with a non-unitary increment, Copy will // panic. // // See the Copier interface for more information. @@ -466,7 +443,7 @@ func (m *Dense) Copy(a Matrix) (r, c int) { // Nothing to do. } } - case *Vector: + case *VecDense: var n, stride int amat := aU.mat if trans { @@ -514,7 +491,7 @@ func (m *Dense) Stack(a, b Matrix) { ar, ac := a.Dims() br, bc := b.Dims() if ac != bc || m == a || m == b { - panic(matrix.ErrShape) + panic(ErrShape) } m.reuseAs(ar+br, ac) @@ -532,7 +509,7 @@ func (m *Dense) Augment(a, b Matrix) { ar, ac := a.Dims() br, bc := b.Dims() if ar != br || m == a || m == b { - panic(matrix.ErrShape) + panic(ErrShape) } m.reuseAs(ar, ac+bc) diff --git a/vendor/github.com/gonum/matrix/mat64/dense_arithmetic.go b/vendor/gonum.org/v1/gonum/mat/dense_arithmetic.go similarity index 92% rename from vendor/github.com/gonum/matrix/mat64/dense_arithmetic.go rename to vendor/gonum.org/v1/gonum/mat/dense_arithmetic.go index 0fc1d85d..e808888e 100644 --- a/vendor/github.com/gonum/matrix/mat64/dense_arithmetic.go +++ b/vendor/gonum.org/v1/gonum/mat/dense_arithmetic.go @@ -1,16 +1,15 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. +// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack/lapack64" ) // Add adds a and b element-wise, placing the result in the receiver. Add @@ -19,7 +18,7 @@ func (m *Dense) Add(a, b Matrix) { ar, ac := a.Dims() br, bc := b.Dims() if ar != br || ac != bc { - panic(matrix.ErrShape) + panic(ErrShape) } aU, _ := untranspose(a) @@ -66,7 +65,7 @@ func (m *Dense) Sub(a, b Matrix) { ar, ac := a.Dims() br, bc := b.Dims() if ar != br || ac != bc { - panic(matrix.ErrShape) + panic(ErrShape) } aU, _ := untranspose(a) @@ -114,7 +113,7 @@ func (m *Dense) MulElem(a, b Matrix) { ar, ac := a.Dims() br, bc := b.Dims() if ar != br || ac != bc { - panic(matrix.ErrShape) + panic(ErrShape) } aU, _ := untranspose(a) @@ -162,7 +161,7 @@ func (m *Dense) DivElem(a, b Matrix) { ar, ac := a.Dims() br, bc := b.Dims() if ar != br || ac != bc { - panic(matrix.ErrShape) + panic(ErrShape) } aU, _ := untranspose(a) @@ -211,7 +210,7 @@ func (m *Dense) Inverse(a Matrix) error { // TODO(btracey): Special case for RawTriangular, etc. r, c := a.Dims() if r != c { - panic(matrix.ErrSquare) + panic(ErrSquare) } m.reuseAs(a.Dims()) aU, aTrans := untranspose(a) @@ -230,27 +229,31 @@ func (m *Dense) Inverse(a Matrix) error { default: m.Copy(a) } - ipiv := make([]int, r) + ipiv := getInts(r, false) + defer putInts(ipiv) ok := lapack64.Getrf(m.mat, ipiv) if !ok { - return matrix.Condition(math.Inf(1)) + return Condition(math.Inf(1)) } - work := make([]float64, 1, 4*r) // must be at least 4*r for cond. + work := getFloats(4*r, false) // must be at least 4*r for cond. lapack64.Getri(m.mat, ipiv, work, -1) if int(work[0]) > 4*r { - work = make([]float64, int(work[0])) + l := int(work[0]) + putFloats(work) + work = getFloats(l, false) } else { work = work[:4*r] } + defer putFloats(work) lapack64.Getri(m.mat, ipiv, work, len(work)) - norm := lapack64.Lange(matrix.CondNorm, m.mat, work) - rcond := lapack64.Gecon(matrix.CondNorm, m.mat, norm, work, ipiv) // reuse ipiv + norm := lapack64.Lange(CondNorm, m.mat, work) + rcond := lapack64.Gecon(CondNorm, m.mat, norm, work, ipiv) // reuse ipiv if rcond == 0 { - return matrix.Condition(math.Inf(1)) + return Condition(math.Inf(1)) } cond := 1 / rcond - if cond > matrix.ConditionTolerance { - return matrix.Condition(cond) + if cond > ConditionTolerance { + return Condition(cond) } return nil } @@ -262,7 +265,7 @@ func (m *Dense) Mul(a, b Matrix) { br, bc := b.Dims() if ac != br { - panic(matrix.ErrShape) + panic(ErrShape) } aU, aTrans := untranspose(a) @@ -335,7 +338,7 @@ func (m *Dense) Mul(a, b Matrix) { blas64.Trmm(blas.Right, bT, 1, bmat, m.mat) return } - if bU, ok := bU.(*Vector); ok { + if bU, ok := bU.(*VecDense); ok { m.checkOverlap(bU.asGeneral()) bvec := bU.RawVector() if bTrans { @@ -396,7 +399,7 @@ func (m *Dense) Mul(a, b Matrix) { blas64.Trmm(blas.Left, aT, 1, amat, m.mat) return } - if aU, ok := aU.(*Vector); ok { + if aU, ok := aU.(*VecDense); ok { m.checkOverlap(aU.asGeneral()) avec := aU.RawVector() if aTrans { @@ -426,7 +429,8 @@ func (m *Dense) Mul(a, b Matrix) { } } - row := make([]float64, ac) + row := getFloats(ac, false) + defer putFloats(row) for r := 0; r < ar; r++ { for i := range row { row[i] = a.At(r, i) @@ -447,7 +451,7 @@ func strictCopy(m *Dense, a Matrix) { if r != m.mat.Rows || c != m.mat.Cols { // Panic with a string since this // is not a user-facing panic. - panic(matrix.ErrShape.Error()) + panic(ErrShape.Error()) } } @@ -459,11 +463,11 @@ func strictCopy(m *Dense, a Matrix) { func (m *Dense) Exp(a Matrix) { r, c := a.Dims() if r != c { - panic(matrix.ErrShape) + panic(ErrShape) } var w *Dense - if m.isZero() { + if m.IsZero() { m.reuseAsZeroed(r, r) w = m } else { @@ -525,7 +529,7 @@ func (m *Dense) Pow(a Matrix, n int) { } r, c := a.Dims() if r != c { - panic(matrix.ErrShape) + panic(ErrShape) } m.reuseAs(r, c) @@ -649,13 +653,13 @@ func (m *Dense) Apply(fn func(i, j int, v float64) float64, a Matrix) { // RankOne performs a rank-one update to the matrix a and stores the result // in the receiver. If a is zero, see Outer. // m = a + alpha * x * y' -func (m *Dense) RankOne(a Matrix, alpha float64, x, y *Vector) { +func (m *Dense) RankOne(a Matrix, alpha float64, x, y *VecDense) { ar, ac := a.Dims() if x.Len() != ar { - panic(matrix.ErrShape) + panic(ErrShape) } if y.Len() != ac { - panic(matrix.ErrShape) + panic(ErrShape) } m.checkOverlap(x.asGeneral()) @@ -679,7 +683,7 @@ func (m *Dense) RankOne(a Matrix, alpha float64, x, y *Vector) { // in the receiver. // m = alpha * x * y' // In order to update an existing matrix, see RankOne. -func (m *Dense) Outer(alpha float64, x, y *Vector) { +func (m *Dense) Outer(alpha float64, x, y *VecDense) { r := x.Len() c := y.Len() @@ -689,10 +693,10 @@ func (m *Dense) Outer(alpha float64, x, y *Vector) { // TODO(kortschak): Factor out into reuseZeroedAs if // we find another case that needs it. if m.mat.Rows > m.capRows || m.mat.Cols > m.capCols { - // Panic as a string, not a mat64.Error. - panic("mat64: caps not correctly set") + // Panic as a string, not a mat.Error. + panic("mat: caps not correctly set") } - if m.isZero() { + if m.IsZero() { m.mat = blas64.General{ Rows: r, Cols: c, @@ -702,7 +706,7 @@ func (m *Dense) Outer(alpha float64, x, y *Vector) { m.capRows = r m.capCols = c } else if r != m.mat.Rows || c != m.mat.Cols { - panic(matrix.ErrShape) + panic(ErrShape) } else { m.checkOverlap(x.asGeneral()) m.checkOverlap(y.asGeneral()) diff --git a/vendor/github.com/gonum/matrix/mat64/doc.go b/vendor/gonum.org/v1/gonum/mat/doc.go similarity index 58% rename from vendor/github.com/gonum/matrix/mat64/doc.go rename to vendor/gonum.org/v1/gonum/mat/doc.go index 61335708..2cc91001 100644 --- a/vendor/github.com/gonum/matrix/mat64/doc.go +++ b/vendor/gonum.org/v1/gonum/mat/doc.go @@ -1,29 +1,26 @@ -// Generated by running -// go generate github.com/gonum/matrix -// DO NOT EDIT. - -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package mat64 provides implementations of float64 matrix structures and -// linear algebra operations on them. +// Package mat provides implementations of float64 and complex128 matrix +// structures and linear algebra operations on them. // // Overview // -// This section provides a quick overview of the mat64 package. The following +// This section provides a quick overview of the mat package. The following // sections provide more in depth commentary. // -// mat64 provides: +// mat provides: // - Interfaces for Matrix classes (Matrix, Symmetric, Triangular) // - Concrete implementations (Dense, SymDense, TriDense) // - Methods and functions for using matrix data (Add, Trace, SymRankOne) // - Types for constructing and using matrix factorizations (QR, LU) +// - The complementary types for complex matrices, CMatrix, CSymDense, etc. // // A matrix may be constructed through the corresponding New function. If no // backing array is provided the matrix will be initialized to all zeros. -// // Allocate a zeroed matrix of size 3×5 -// zero := mat64.NewDense(3, 5, nil) +// // Allocate a zeroed real matrix of size 3×5 +// zero := mat.NewDense(3, 5, nil) // If a backing data slice is provided, the matrix will have those elements. // Matrices are all stored in row-major format. // // Generate a 6×6 matrix of random values. @@ -31,28 +28,40 @@ // for i := range data { // data[i] = rand.NormFloat64() // } -// a := mat64.NewDense(6, 6, data) -// +// a := mat.NewDense(6, 6, data) // Operations involving matrix data are implemented as functions when the values // of the matrix remain unchanged -// tr := mat64.Trace(a) +// tr := mat.Trace(a) // and are implemented as methods when the operation modifies the receiver. // zero.Copy(a) // // Receivers must be the correct size for the matrix operations, otherwise the -// operation will panic. As a special case for convenience, a zero-sized matrix +// operation will panic. As a special case for convenience, a zero-value matrix // will be modified to have the correct size, allocating data if necessary. -// var c mat64.Dense // construct a new zero-sized matrix -// c.Mul(a, a) // c is automatically adjusted to be 6×6 +// var c mat.Dense // construct a new zero-sized matrix +// c.Mul(a, a) // c is automatically adjusted to be 6×6 +// +// Zero-value of a matrix +// +// A zero-value matrix is either the Go language definition of a zero-value or +// is a zero-sized matrix with zero-length stride. Matrix implementations may have +// a Reset method to revert the receiver into a zero-valued matrix and an IsZero +// method that returns whether the matrix is zero-valued. +// So the following will all result in a zero-value matrix. +// - var a mat.Dense +// - a := NewDense(0, 0, make([]float64, 0, 100)) +// - a.Reset() +// A zero-value matrix can not be sliced even if it does have an adequately sized +// backing data slice, but can be expanded using its Grow method if it exists. // // The Matrix Interfaces // -// The Matrix interface is the common link between the concrete types. The Matrix -// interface is defined by three functions: Dims, which returns the dimensions -// of the Matrix, At, which returns the element in the specified location, and -// T for returning a Transpose (discussed later). All of the concrete types can -// perform these behaviors and so implement the interface. Methods and functions -// are designed to use this interface, so in particular the method +// The Matrix interface is the common link between the concrete types of real +// matrices, The Matrix interface is defined by three functions: Dims, which +// returns the dimensions of the Matrix, At, which returns the element in the +// specified location, and T for returning a Transpose (discussed later). All of +// the concrete types can perform these behaviors and so implement the interface. +// Methods and functions are designed to use this interface, so in particular the method // func (m *Dense) Mul(a, b Matrix) // constructs a *Dense from the result of a multiplication with any Matrix types, // not just *Dense. Where more restrictive requirements must be met, there are also the @@ -60,34 +69,40 @@ // func (s *SymDense) AddSym(a, b Symmetric) // the Symmetric interface guarantees a symmetric result. // -// Transposes +// The CMatrix interface plays the same role for complex matrices. The difference +// is that the CMatrix type has the H method instead T, for returning the conjugate +// transpose. // -// The T method is used for transposition. For example, c.Mul(a.T(), b) computes -// c = a^T * b. The mat64 types implement this method using an implicit transpose — -// see the Transpose type for more details. Note that some operations have a -// transpose as part of their definition, as in *SymDense.SymOuterK. +// (Conjugate) Transposes +// +// The T method is used for transposition on real matrices, and H is used for +// conjugate transposition on complex matrices. For example, c.Mul(a.T(), b) computes +// c = a^T * b. The mat types implement this method implicitly — +// see the Transpose and Conjugate types for more details. Note that some +// operations have a transpose as part of their definition, as in *SymDense.SymOuterK. // // Matrix Factorization // // Matrix factorizations, such as the LU decomposition, typically have their own // specific data storage, and so are each implemented as a specific type. The // factorization can be computed through a call to Factorize -// var lu mat64.LU +// var lu mat.LU // lu.Factorize(a) // The elements of the factorization can be extracted through methods on the -// appropriate type, i.e. *TriDense.LFromLU and *TriDense.UFromLU. Alternatively, -// they can be used directly, as in *Dense.SolveLU. Some factorizations can be -// updated directly, without needing to update the original matrix and refactorize, +// factorized type, i.e. *LU.UTo. The factorization types can also be used directly, +// as in *Dense.SolveCholesky. Some factorizations can be updated directly, +// without needing to update the original matrix and refactorize, // as in *LU.RankOne. // // BLAS and LAPACK // // BLAS and LAPACK are the standard APIs for linear algebra routines. Many -// operations in mat64 are implemented using calls to the wrapper functions -// in gonum/blas/blas64 and gonum/lapack/lapack64. By default, blas64 and -// lapack64 call the native Go implementations of the routines. Alternatively, -// it is possible to use C-based implementations of the APIs through the respective -// cgo packages and "Use" functions. The Go implementation of LAPACK makes calls +// operations in mat are implemented using calls to the wrapper functions +// in gonum/blas/blas64 and gonum/lapack/lapack64 and their complex equivalents. +// By default, blas64 and lapack64 call the native Go implementations of the +// routines. Alternatively, it is possible to use C-based implementations of the +// APIs through the respective cgo packages and "Use" functions. The Go +// implementation of LAPACK (used by default) makes calls // through blas64, so if a cgo BLAS implementation is registered, the lapack64 // calls will be partially executed in Go and partially executed in C. // @@ -100,7 +115,7 @@ // if a and b both implement RawMatrixer, that is, they can be represented as a // blas64.General, blas64.Gemm (general matrix multiplication) is called, while // instead if b is a RawSymmetricer blas64.Symm is used (general-symmetric -// multiplication), and if b is a *Vector blas64.Gemv is used. +// multiplication), and if b is a *VecDense blas64.Gemv is used. // // There are many possible type combinations and special cases. No specific guarantees // are made about the performance of any method, and in particular, note that an @@ -121,26 +136,24 @@ // // Element Aliasing // -// Most methods in mat64 modify receiver data. It is forbidden for the modified +// Most methods in mat modify receiver data. It is forbidden for the modified // data region of the receiver to overlap the used data area of the input // arguments. The exception to this rule is when the method receiver is equal to one // of the input arguments, as in the a.Pow(a, 6) call above, or its implicit transpose. // // This prohibition is to help avoid subtle mistakes when the method needs to read // from and write to the same data region. There are ways to make mistakes using the -// mat64 API, and mat64 functions will detect and complain about those. -// There are many ways to make mistakes by excursion from the mat64 API via +// mat API, and mat functions will detect and complain about those. +// There are many ways to make mistakes by excursion from the mat API via // interaction with raw matrix values. // // If you need to read the rest of this section to understand the behavior of // your program, you are being clever. Don't be clever. If you must be clever, // blas64 and lapack64 may be used to call the behavior directly. // -// mat64 will use the following rules to detect overlap between the receiver and one +// mat will use the following rules to detect overlap between the receiver and one // of the inputs: // - the input implements one of the Raw methods, and -// - the Raw type matches that of the receiver or -// one is a RawMatrixer and the other is a RawVectorer, and // - the address ranges of the backing data slices overlap, and // - the strides differ or there is an overlap in the used data elements. // If such an overlap is detected, the method will panic. @@ -150,9 +163,7 @@ // - there is pointer identity between the receiver and input values after // the value has been untransposed if necessary. // -// mat64 will not attempt to detect element overlap if the input does not implement a -// Raw method, or if the Raw method differs from that of the receiver except when a -// conversion has occurred through a mat64 API function. Method behavior is undefined -// if there is undetected overlap. +// mat will not attempt to detect element overlap if the input does not implement a +// Raw method. Method behavior is undefined if there is undetected overlap. // -package mat64 +package mat // import "gonum.org/v1/gonum/mat" diff --git a/vendor/github.com/gonum/matrix/mat64/eigen.go b/vendor/gonum.org/v1/gonum/mat/eigen.go similarity index 89% rename from vendor/github.com/gonum/matrix/mat64/eigen.go rename to vendor/gonum.org/v1/gonum/mat/eigen.go index d7994b03..ac9de809 100644 --- a/vendor/github.com/gonum/matrix/mat64/eigen.go +++ b/vendor/gonum.org/v1/gonum/mat/eigen.go @@ -1,32 +1,19 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. +// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( - "github.com/gonum/lapack" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/lapack" + "gonum.org/v1/gonum/lapack/lapack64" ) const ( - badFact = "mat64: use without successful factorization" - badNoVect = "mat64: eigenvectors not computed" + badFact = "mat: use without successful factorization" + badNoVect = "mat: eigenvectors not computed" ) -func symmetric(m *Dense) bool { - n, _ := m.Dims() - for i := 0; i < n; i++ { - for j := 0; j < i; j++ { - if m.at(i, j) != m.at(j, i) { - return false - } - } - } - return true -} - // EigenSym is a type for creating and manipulating the Eigen decomposition of // symmetric matrices. type EigenSym struct { @@ -55,11 +42,12 @@ func (e *EigenSym) Factorize(a Symmetric, vectors bool) (ok bool) { jobz = lapack.ComputeEV } w := make([]float64, n) - work := make([]float64, 1) + work := []float64{0} lapack64.Syev(jobz, sd.mat, w, work, -1) - work = make([]float64, int(work[0])) + work = getFloats(int(work[0]), false) ok = lapack64.Syev(jobz, sd.mat, w, work, len(work)) + putFloats(work) if !ok { e.vectorsComputed = false e.values = nil @@ -92,7 +80,7 @@ func (e *EigenSym) Values(dst []float64) []float64 { dst = make([]float64, len(e.values)) } if len(dst) != len(e.values) { - panic(matrix.ErrSliceLengthMismatch) + panic(ErrSliceLengthMismatch) } copy(dst, e.values) return dst @@ -153,13 +141,13 @@ func (e *Eigen) succFact() bool { // Factorize returns whether the decomposition succeeded. If the decomposition // failed, methods that require a successful factorization will panic. func (e *Eigen) Factorize(a Matrix, left, right bool) (ok bool) { - // TODO(btracey): Change implementation to store Vectors as a *CMat when + // TODO(btracey): Change implementation to store VecDenses as a *CMat when // #308 is resolved. // Copy a because it is modified during the Lapack call. r, c := a.Dims() if r != c { - panic(matrix.ErrShape) + panic(ErrShape) } var sd Dense sd.Clone(a) @@ -176,13 +164,16 @@ func (e *Eigen) Factorize(a Matrix, left, right bool) (ok bool) { jobvr = lapack.ComputeRightEV } - wr := make([]float64, c) - wi := make([]float64, c) + wr := getFloats(c, false) + defer putFloats(wr) + wi := getFloats(c, false) + defer putFloats(wi) - work := make([]float64, 1) + work := []float64{0} lapack64.Geev(jobvl, jobvr, sd.mat, wr, wi, vl.mat, vr.mat, work, -1) - work = make([]float64, int(work[0])) + work = getFloats(int(work[0]), false) first := lapack64.Geev(jobvl, jobvr, sd.mat, wr, wi, vl.mat, vr.mat, work, len(work)) + putFloats(work) if first != 0 { e.values = nil @@ -216,7 +207,7 @@ func (e *Eigen) Values(dst []complex128) []complex128 { dst = make([]complex128, e.n) } if len(dst) != e.n { - panic(matrix.ErrSliceLengthMismatch) + panic(ErrSliceLengthMismatch) } copy(dst, e.values) return dst diff --git a/vendor/github.com/gonum/matrix/errors.go b/vendor/gonum.org/v1/gonum/mat/errors.go similarity index 89% rename from vendor/github.com/gonum/matrix/errors.go rename to vendor/gonum.org/v1/gonum/mat/errors.go index 74d0ea90..99e2b880 100644 --- a/vendor/github.com/gonum/matrix/errors.go +++ b/vendor/gonum.org/v1/gonum/mat/errors.go @@ -1,18 +1,18 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. +// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package matrix +package mat import ( "fmt" "runtime" - "github.com/gonum/lapack" + "gonum.org/v1/gonum/lapack" ) // Condition is the condition number of a matrix. The condition -// number is defined as ||A|| * ||A^-1||. +// number is defined as |A| * |A^-1|. // // One important use of Condition is during linear solve routines (finding x such // that A * x = b). The condition number of A indicates the accuracy of @@ -44,7 +44,7 @@ const ( const stackTraceBufferSize = 1 << 20 -// Maybe will recover a panic with a type mat64.Error from fn, and return this error +// Maybe will recover a panic with a type mat.Error from fn, and return this error // as the Err field of an ErrorStack. The stack trace for the panicking function will be // recovered and placed in the StackTrace field. Any other error is re-panicked. func Maybe(fn func()) (err error) { @@ -52,7 +52,7 @@ func Maybe(fn func()) (err error) { if r := recover(); r != nil { if e, ok := r.(Error); ok { if e.string == "" { - panic("mat64: invalid error") + panic("mat: invalid error") } buf := make([]byte, stackTraceBufferSize) n := runtime.Stack(buf, false) @@ -66,7 +66,7 @@ func Maybe(fn func()) (err error) { return } -// MaybeFloat will recover a panic with a type mat64.Error from fn, and return this error +// MaybeFloat will recover a panic with a type mat.Error from fn, and return this error // as the Err field of an ErrorStack. The stack trace for the panicking function will be // recovered and placed in the StackTrace field. Any other error is re-panicked. func MaybeFloat(fn func() float64) (f float64, err error) { @@ -74,7 +74,7 @@ func MaybeFloat(fn func() float64) (f float64, err error) { if r := recover(); r != nil { if e, ok := r.(Error); ok { if e.string == "" { - panic("mat64: invalid error") + panic("mat: invalid error") } buf := make([]byte, stackTraceBufferSize) n := runtime.Stack(buf, false) @@ -87,7 +87,7 @@ func MaybeFloat(fn func() float64) (f float64, err error) { return fn(), nil } -// MaybeComplex will recover a panic with a type mat64.Error from fn, and return this error +// MaybeComplex will recover a panic with a type mat.Error from fn, and return this error // as the Err field of an ErrorStack. The stack trace for the panicking function will be // recovered and placed in the StackTrace field. Any other error is re-panicked. func MaybeComplex(fn func() complex128) (f complex128, err error) { @@ -95,7 +95,7 @@ func MaybeComplex(fn func() complex128) (f complex128, err error) { if r := recover(); r != nil { if e, ok := r.(Error); ok { if e.string == "" { - panic("mat64: invalid error") + panic("mat: invalid error") } buf := make([]byte, stackTraceBufferSize) n := runtime.Stack(buf, false) @@ -129,6 +129,7 @@ var ( ErrPivot = Error{"matrix: malformed pivot list"} ErrTriangle = Error{"matrix: triangular storage mismatch"} ErrTriangleSet = Error{"matrix: triangular set out of bounds"} + ErrBandSet = Error{"matrix: band set out of bounds"} ErrSliceLengthMismatch = Error{"matrix: input slice length mismatch"} ErrNotPSD = Error{"matrix: input not positive symmetric definite"} ErrFailedEigen = Error{"matrix: eigendecomposition not successful"} diff --git a/vendor/github.com/gonum/matrix/mat64/format.go b/vendor/gonum.org/v1/gonum/mat/format.go similarity index 98% rename from vendor/github.com/gonum/matrix/mat64/format.go rename to vendor/gonum.org/v1/gonum/mat/format.go index 5d01247d..ce72eb19 100644 --- a/vendor/github.com/gonum/matrix/mat64/format.go +++ b/vendor/gonum.org/v1/gonum/mat/format.go @@ -1,8 +1,8 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. +// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( "fmt" diff --git a/vendor/github.com/gonum/matrix/mat64/gsvd.go b/vendor/gonum.org/v1/gonum/mat/gsvd.go similarity index 64% rename from vendor/github.com/gonum/matrix/mat64/gsvd.go rename to vendor/gonum.org/v1/gonum/mat/gsvd.go index 9c1801bd..f2b82cb5 100644 --- a/vendor/github.com/gonum/matrix/mat64/gsvd.go +++ b/vendor/gonum.org/v1/gonum/mat/gsvd.go @@ -1,15 +1,14 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( - "github.com/gonum/blas/blas64" - "github.com/gonum/floats" - "github.com/gonum/lapack" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/floats" + "gonum.org/v1/gonum/lapack" + "gonum.org/v1/gonum/lapack/lapack64" ) // GSVD is a type for creating and using the Generalized Singular Value Decomposition @@ -19,7 +18,7 @@ import ( // variable×sample spaces to reduced and diagonalized "eigenvariable"×"eigensample" // spaces. type GSVD struct { - kind matrix.GSVDKind + kind GSVDKind r, p, c, k, l int s1, s2 []float64 @@ -49,24 +48,24 @@ type GSVD struct { // // Factorize returns whether the decomposition succeeded. If the decomposition // failed, routines that require a successful factorization will panic. -func (gsvd *GSVD) Factorize(a, b Matrix, kind matrix.GSVDKind) (ok bool) { +func (gsvd *GSVD) Factorize(a, b Matrix, kind GSVDKind) (ok bool) { r, c := a.Dims() gsvd.r, gsvd.c = r, c p, c := b.Dims() gsvd.p = p if gsvd.c != c { - panic(matrix.ErrShape) + panic(ErrShape) } var jobU, jobV, jobQ lapack.GSVDJob switch { default: panic("gsvd: bad input kind") - case kind == matrix.GSVDNone: + case kind == GSVDNone: jobU = lapack.GSVDNone jobV = lapack.GSVDNone jobQ = lapack.GSVDNone - case (matrix.GSVDU|matrix.GSVDV|matrix.GSVDQ)&kind != 0: - if matrix.GSVDU&kind != 0 { + case (GSVDU|GSVDV|GSVDQ)&kind != 0: + if GSVDU&kind != 0 { jobU = lapack.GSVDU gsvd.u = blas64.General{ Rows: r, @@ -75,7 +74,7 @@ func (gsvd *GSVD) Factorize(a, b Matrix, kind matrix.GSVDKind) (ok bool) { Data: use(gsvd.u.Data, r*r), } } - if matrix.GSVDV&kind != 0 { + if GSVDV&kind != 0 { jobV = lapack.GSVDV gsvd.v = blas64.General{ Rows: p, @@ -84,7 +83,7 @@ func (gsvd *GSVD) Factorize(a, b Matrix, kind matrix.GSVDKind) (ok bool) { Data: use(gsvd.v.Data, p*p), } } - if matrix.GSVDQ&kind != 0 { + if GSVDQ&kind != 0 { jobQ = lapack.GSVDQ gsvd.q = blas64.General{ Rows: c, @@ -118,7 +117,7 @@ func (gsvd *GSVD) Factorize(a, b Matrix, kind matrix.GSVDKind) (ok bool) { // Kind returns the matrix.GSVDKind of the decomposition. If no decomposition has been // computed, Kind returns 0. -func (gsvd *GSVD) Kind() matrix.GSVDKind { +func (gsvd *GSVD) Kind() GSVDKind { return gsvd.kind } @@ -146,7 +145,7 @@ func (gsvd *GSVD) GeneralizedValues(v []float64) []float64 { v = make([]float64, d-k) } if len(v) != d-k { - panic(matrix.ErrSliceLengthMismatch) + panic(ErrSliceLengthMismatch) } floats.DivTo(v, gsvd.s1[k:d], gsvd.s2[k:d]) return v @@ -171,7 +170,7 @@ func (gsvd *GSVD) ValuesA(s []float64) []float64 { s = make([]float64, d-k) } if len(s) != d-k { - panic(matrix.ErrSliceLengthMismatch) + panic(ErrSliceLengthMismatch) } copy(s, gsvd.s1[k:min(r, c)]) return s @@ -196,15 +195,18 @@ func (gsvd *GSVD) ValuesB(s []float64) []float64 { s = make([]float64, d-k) } if len(s) != d-k { - panic(matrix.ErrSliceLengthMismatch) + panic(ErrSliceLengthMismatch) } copy(s, gsvd.s2[k:d]) return s } -// ZeroRFromGSVD extracts the matrix [ 0 R ] from the singular value decomposition, storing -// the result in-place into the receiver. [ 0 R ] is size (k+l)×c. -func (m *Dense) ZeroRFromGSVD(gsvd *GSVD) { +// ZeroRTo extracts the matrix [ 0 R ] from the singular value decomposition, storing +// the result in-place into dst. [ 0 R ] is size (k+l)×c. +// If dst is nil, a new matrix is allocated. The resulting ZeroR matrix is returned. +// +// ZeroRTo will panic if the receiver does not contain a successful factorization. +func (gsvd *GSVD) ZeroRTo(dst *Dense) *Dense { if gsvd.kind == 0 { panic("gsvd: no decomposition computed") } @@ -213,13 +215,17 @@ func (m *Dense) ZeroRFromGSVD(gsvd *GSVD) { k := gsvd.k l := gsvd.l h := min(k+l, r) - m.reuseAsZeroed(k+l, c) + if dst == nil { + dst = NewDense(k+l, c, nil) + } else { + dst.reuseAsZeroed(k+l, c) + } a := Dense{ mat: gsvd.a, capRows: r, capCols: c, } - m.Slice(0, h, c-k-l, c).(*Dense). + dst.Slice(0, h, c-k-l, c).(*Dense). Copy(a.Slice(0, h, c-k-l, c)) if r < k+l { b := Dense{ @@ -227,32 +233,44 @@ func (m *Dense) ZeroRFromGSVD(gsvd *GSVD) { capRows: gsvd.p, capCols: c, } - m.Slice(r, k+l, c+r-k-l, c).(*Dense). + dst.Slice(r, k+l, c+r-k-l, c).(*Dense). Copy(b.Slice(r-k, l, c+r-k-l, c)) } + return dst } -// SigmaAFromGSVD extracts the matrix Σ₁ from the singular value decomposition, storing -// the result in-place into the receiver. Σ₁ is size r×(k+l). -func (m *Dense) SigmaAFromGSVD(gsvd *GSVD) { +// SigmaATo extracts the matrix Σ₁ from the singular value decomposition, storing +// the result in-place into dst. Σ₁ is size r×(k+l). +// If dst is nil, a new matrix is allocated. The resulting SigmaA matrix is returned. +// +// SigmaATo will panic if the receiver does not contain a successful factorization. +func (gsvd *GSVD) SigmaATo(dst *Dense) *Dense { if gsvd.kind == 0 { panic("gsvd: no decomposition computed") } r := gsvd.r k := gsvd.k l := gsvd.l - m.reuseAsZeroed(r, k+l) + if dst == nil { + dst = NewDense(r, k+l, nil) + } else { + dst.reuseAsZeroed(r, k+l) + } for i := 0; i < k; i++ { - m.set(i, i, 1) + dst.set(i, i, 1) } for i := k; i < min(r, k+l); i++ { - m.set(i, i, gsvd.s1[i]) + dst.set(i, i, gsvd.s1[i]) } + return dst } -// SigmaBFromGSVD extracts the matrix Σ₂ from the singular value decomposition, storing -// the result in-place into the receiver. Σ₂ is size p×(k+l). -func (m *Dense) SigmaBFromGSVD(gsvd *GSVD) { +// SigmaBTo extracts the matrix Σ₂ from the singular value decomposition, storing +// the result in-place into dst. Σ₂ is size p×(k+l). +// If dst is nil, a new matrix is allocated. The resulting SigmaB matrix is returned. +// +// SigmaBTo will panic if the receiver does not contain a successful factorization. +func (gsvd *GSVD) SigmaBTo(dst *Dense) *Dense { if gsvd.kind == 0 { panic("gsvd: no decomposition computed") } @@ -260,65 +278,94 @@ func (m *Dense) SigmaBFromGSVD(gsvd *GSVD) { p := gsvd.p k := gsvd.k l := gsvd.l - m.reuseAsZeroed(p, k+l) + if dst == nil { + dst = NewDense(p, k+l, nil) + } else { + dst.reuseAsZeroed(p, k+l) + } for i := 0; i < min(l, r-k); i++ { - m.set(i, i+k, gsvd.s2[k+i]) + dst.set(i, i+k, gsvd.s2[k+i]) } for i := r - k; i < l; i++ { - m.set(i, i+k, 1) + dst.set(i, i+k, 1) } + return dst } -// UFromGSVD extracts the matrix U from the singular value decomposition, storing -// the result in-place into the receiver. U is size r×r. -func (m *Dense) UFromGSVD(gsvd *GSVD) { - if gsvd.kind&matrix.GSVDU == 0 { - panic("mat64: improper GSVD kind") +// UTo extracts the matrix U from the singular value decomposition, storing +// the result in-place into dst. U is size r×r. +// If dst is nil, a new matrix is allocated. The resulting U matrix is returned. +// +// UTo will panic if the receiver does not contain a successful factorization. +func (gsvd *GSVD) UTo(dst *Dense) *Dense { + if gsvd.kind&GSVDU == 0 { + panic("mat: improper GSVD kind") } r := gsvd.u.Rows c := gsvd.u.Cols - m.reuseAs(r, c) + if dst == nil { + dst = NewDense(r, c, nil) + } else { + dst.reuseAs(r, c) + } tmp := &Dense{ mat: gsvd.u, capRows: r, capCols: c, } - m.Copy(tmp) + dst.Copy(tmp) + return dst } -// VFromGSVD extracts the matrix V from the singular value decomposition, storing -// the result in-place into the receiver. V is size p×p. -func (m *Dense) VFromGSVD(gsvd *GSVD) { - if gsvd.kind&matrix.GSVDV == 0 { - panic("mat64: improper GSVD kind") +// VTo extracts the matrix V from the singular value decomposition, storing +// the result in-place into dst. V is size p×p. +// If dst is nil, a new matrix is allocated. The resulting V matrix is returned. +// +// VTo will panic if the receiver does not contain a successful factorization. +func (gsvd *GSVD) VTo(dst *Dense) *Dense { + if gsvd.kind&GSVDV == 0 { + panic("mat: improper GSVD kind") } r := gsvd.v.Rows c := gsvd.v.Cols - m.reuseAs(r, c) + if dst == nil { + dst = NewDense(r, c, nil) + } else { + dst.reuseAs(r, c) + } tmp := &Dense{ mat: gsvd.v, capRows: r, capCols: c, } - m.Copy(tmp) + dst.Copy(tmp) + return dst } -// QFromGSVD extracts the matrix Q from the singular value decomposition, storing -// the result in-place into the receiver. Q is size c×c. -func (m *Dense) QFromGSVD(gsvd *GSVD) { - if gsvd.kind&matrix.GSVDQ == 0 { - panic("mat64: improper GSVD kind") +// QTo extracts the matrix Q from the singular value decomposition, storing +// the result in-place into dst. Q is size c×c. +// If dst is nil, a new matrix is allocated. The resulting Q matrix is returned. +// +// QTo will panic if the receiver does not contain a successful factorization. +func (gsvd *GSVD) QTo(dst *Dense) *Dense { + if gsvd.kind&GSVDQ == 0 { + panic("mat: improper GSVD kind") } r := gsvd.q.Rows c := gsvd.q.Cols - m.reuseAs(r, c) + if dst == nil { + dst = NewDense(r, c, nil) + } else { + dst.reuseAs(r, c) + } tmp := &Dense{ mat: gsvd.q, capRows: r, capCols: c, } - m.Copy(tmp) + dst.Copy(tmp) + return dst } diff --git a/vendor/github.com/gonum/matrix/mat64/hogsvd.go b/vendor/gonum.org/v1/gonum/mat/hogsvd.go similarity index 73% rename from vendor/github.com/gonum/matrix/mat64/hogsvd.go rename to vendor/gonum.org/v1/gonum/mat/hogsvd.go index 4d70a93b..4b0a8ba6 100644 --- a/vendor/github.com/gonum/matrix/mat64/hogsvd.go +++ b/vendor/gonum.org/v1/gonum/mat/hogsvd.go @@ -1,14 +1,13 @@ -// Copyright ©2017 The gonum Authors. All rights reserved. +// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( "errors" - "github.com/gonum/blas/blas64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas/blas64" ) // HOGSVD is a type for creating and using the Higher Order Generalized Singular Value @@ -57,14 +56,14 @@ func (gsvd *HOGSVD) Factorize(m ...Matrix) (ok bool) { for i, d := range m { rd, cd := d.Dims() if rd < cd { - gsvd.err = matrix.ErrShape + gsvd.err = ErrShape return false } if rd > r { r = rd } if cd != c { - panic(matrix.ErrShape) + panic(ErrShape) } ts.Reset() ts.SymOuterK(1, d.T()) @@ -81,13 +80,13 @@ func (gsvd *HOGSVD) Factorize(m ...Matrix) (ok bool) { defer putWorkspace(sij) for i, ai := range a { for _, aj := range a[i+1:] { - gsvd.err = sij.solveTwoChol(&ai, &aj) + gsvd.err = ai.SolveChol(sij, &aj) if gsvd.err != nil { return false } s.Add(s, sij) - gsvd.err = sij.solveTwoChol(&aj, &ai) + gsvd.err = aj.SolveChol(sij, &ai) if gsvd.err != nil { return false } @@ -103,9 +102,10 @@ func (gsvd *HOGSVD) Factorize(m ...Matrix) (ok bool) { return false } v := eig.Vectors() + var cv VecDense for j := 0; j < c; j++ { - cv := v.ColView(j) - cv.ScaleVec(1/blas64.Nrm2(c, cv.mat), cv) + cv.ColViewOf(v, j) + cv.ScaleVec(1/blas64.Nrm2(c, cv.mat), &cv) } b := make([]Dense, len(m)) @@ -140,11 +140,12 @@ func (gsvd *HOGSVD) Len() int { return gsvd.n } -// UFromHOGSVD extracts the matrix U_n from the singular value decomposition, storing -// the result in-place into the receiver. U_n is size r×c. +// UTo extracts the matrix U_n from the singular value decomposition, storing +// the result in-place into dst. U_n is size r×c. +// If dst is nil, a new matrix is allocated. The resulting U matrix is returned. // -// UFromHOGSVD will panic if the receiver does not contain a successful factorization. -func (m *Dense) UFromHOGSVD(gsvd *HOGSVD, n int) { +// UTo will panic if the receiver does not contain a successful factorization. +func (gsvd *HOGSVD) UTo(dst *Dense, n int) *Dense { if gsvd.n == 0 { panic("hogsvd: unsuccessful factorization") } @@ -152,12 +153,19 @@ func (m *Dense) UFromHOGSVD(gsvd *HOGSVD, n int) { panic("hogsvd: invalid index") } - m.reuseAs(gsvd.b[n].Dims()) - m.Copy(&gsvd.b[n]) - for j, f := range gsvd.Values(nil, n) { - v := m.ColView(j) - v.ScaleVec(1/f, v) + if dst == nil { + r, c := gsvd.b[n].Dims() + dst = NewDense(r, c, nil) + } else { + dst.reuseAs(gsvd.b[n].Dims()) } + dst.Copy(&gsvd.b[n]) + var v VecDense + for j, f := range gsvd.Values(nil, n) { + v.ColViewOf(dst, j) + v.ScaleVec(1/f, &v) + } + return dst } // Values returns the nth set of singular values of the factorized system. @@ -179,21 +187,31 @@ func (gsvd *HOGSVD) Values(s []float64, n int) []float64 { if s == nil { s = make([]float64, c) } else if len(s) != c { - panic(matrix.ErrSliceLengthMismatch) + panic(ErrSliceLengthMismatch) } + var v VecDense for j := 0; j < c; j++ { - s[j] = blas64.Nrm2(r, gsvd.b[n].ColView(j).mat) + v.ColViewOf(&gsvd.b[n], j) + s[j] = blas64.Nrm2(r, v.mat) } return s } -// VFromHOGSVD extracts the matrix V from the singular value decomposition, storing -// the result in-place into the receiver. V is size c×c. +// VTo extracts the matrix V from the singular value decomposition, storing +// the result in-place into dst. V is size c×c. +// If dst is nil, a new matrix is allocated. The resulting V matrix is returned. // -// VFromHOGSVD will panic if the receiver does not contain a successful factorization. -func (m *Dense) VFromHOGSVD(gsvd *HOGSVD) { +// VTo will panic if the receiver does not contain a successful factorization. +func (gsvd *HOGSVD) VTo(dst *Dense) *Dense { if gsvd.n == 0 { panic("hogsvd: unsuccessful factorization") } - *m = *DenseCopyOf(gsvd.v) + if dst == nil { + r, c := gsvd.v.Dims() + dst = NewDense(r, c, nil) + } else { + dst.reuseAs(gsvd.v.Dims()) + } + dst.Copy(gsvd.v) + return dst } diff --git a/vendor/gonum.org/v1/gonum/mat/index_bound_checks.go b/vendor/gonum.org/v1/gonum/mat/index_bound_checks.go new file mode 100644 index 00000000..bb1fe5b6 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/mat/index_bound_checks.go @@ -0,0 +1,233 @@ +// Copyright ©2014 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file must be kept in sync with index_no_bound_checks.go. + +//+build bounds + +package mat + +// At returns the element at row i, column j. +func (m *Dense) At(i, j int) float64 { + return m.at(i, j) +} + +func (m *Dense) at(i, j int) float64 { + if uint(i) >= uint(m.mat.Rows) { + panic(ErrRowAccess) + } + if uint(j) >= uint(m.mat.Cols) { + panic(ErrColAccess) + } + return m.mat.Data[i*m.mat.Stride+j] +} + +// Set sets the element at row i, column j to the value v. +func (m *Dense) Set(i, j int, v float64) { + m.set(i, j, v) +} + +func (m *Dense) set(i, j int, v float64) { + if uint(i) >= uint(m.mat.Rows) { + panic(ErrRowAccess) + } + if uint(j) >= uint(m.mat.Cols) { + panic(ErrColAccess) + } + m.mat.Data[i*m.mat.Stride+j] = v +} + +// At returns the element at row i. +// It panics if i is out of bounds or if j is not zero. +func (v *VecDense) At(i, j int) float64 { + if j != 0 { + panic(ErrColAccess) + } + return v.at(i) +} + +// AtVec returns the element at row i. +// It panics if i is out of bounds. +func (v *VecDense) AtVec(i int) float64 { + return v.at(i) +} + +func (v *VecDense) at(i int) float64 { + if uint(i) >= uint(v.n) { + panic(ErrRowAccess) + } + return v.mat.Data[i*v.mat.Inc] +} + +// SetVec sets the element at row i to the value val. +// It panics if i is out of bounds. +func (v *VecDense) SetVec(i int, val float64) { + v.setVec(i, val) +} + +func (v *VecDense) setVec(i int, val float64) { + if uint(i) >= uint(v.n) { + panic(ErrVectorAccess) + } + v.mat.Data[i*v.mat.Inc] = val +} + +// At returns the element at row i and column j. +func (t *SymDense) At(i, j int) float64 { + return t.at(i, j) +} + +func (t *SymDense) at(i, j int) float64 { + if uint(i) >= uint(t.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(t.mat.N) { + panic(ErrColAccess) + } + if i > j { + i, j = j, i + } + return t.mat.Data[i*t.mat.Stride+j] +} + +// SetSym sets the elements at (i,j) and (j,i) to the value v. +func (t *SymDense) SetSym(i, j int, v float64) { + t.set(i, j, v) +} + +func (t *SymDense) set(i, j int, v float64) { + if uint(i) >= uint(t.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(t.mat.N) { + panic(ErrColAccess) + } + if i > j { + i, j = j, i + } + t.mat.Data[i*t.mat.Stride+j] = v +} + +// At returns the element at row i, column j. +func (t *TriDense) At(i, j int) float64 { + return t.at(i, j) +} + +func (t *TriDense) at(i, j int) float64 { + if uint(i) >= uint(t.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(t.mat.N) { + panic(ErrColAccess) + } + isUpper := t.isUpper() + if (isUpper && i > j) || (!isUpper && i < j) { + return 0 + } + return t.mat.Data[i*t.mat.Stride+j] +} + +// SetTri sets the element of the triangular matrix at row i, column j to the value v. +// It panics if the location is outside the appropriate half of the matrix. +func (t *TriDense) SetTri(i, j int, v float64) { + t.set(i, j, v) +} + +func (t *TriDense) set(i, j int, v float64) { + if uint(i) >= uint(t.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(t.mat.N) { + panic(ErrColAccess) + } + isUpper := t.isUpper() + if (isUpper && i > j) || (!isUpper && i < j) { + panic(ErrTriangleSet) + } + t.mat.Data[i*t.mat.Stride+j] = v +} + +// At returns the element at row i, column j. +func (b *BandDense) At(i, j int) float64 { + return b.at(i, j) +} + +func (b *BandDense) at(i, j int) float64 { + if uint(i) >= uint(b.mat.Rows) { + panic(ErrRowAccess) + } + if uint(j) >= uint(b.mat.Cols) { + panic(ErrColAccess) + } + pj := j + b.mat.KL - i + if pj < 0 || b.mat.KL+b.mat.KU+1 <= pj { + return 0 + } + return b.mat.Data[i*b.mat.Stride+pj] +} + +// SetBand sets the element at row i, column j to the value v. +// It panics if the location is outside the appropriate region of the matrix. +func (b *BandDense) SetBand(i, j int, v float64) { + b.set(i, j, v) +} + +func (b *BandDense) set(i, j int, v float64) { + if uint(i) >= uint(b.mat.Rows) { + panic(ErrRowAccess) + } + if uint(j) >= uint(b.mat.Cols) { + panic(ErrColAccess) + } + pj := j + b.mat.KL - i + if pj < 0 || b.mat.KL+b.mat.KU+1 <= pj { + panic(ErrBandSet) + } + b.mat.Data[i*b.mat.Stride+pj] = v +} + +// At returns the element at row i, column j. +func (s *SymBandDense) At(i, j int) float64 { + return s.at(i, j) +} + +func (s *SymBandDense) at(i, j int) float64 { + if uint(i) >= uint(s.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(s.mat.N) { + panic(ErrColAccess) + } + if i > j { + i, j = j, i + } + pj := j - i + if s.mat.K+1 <= pj { + return 0 + } + return s.mat.Data[i*s.mat.Stride+pj] +} + +// SetSymBand sets the element at row i, column j to the value v. +// It panics if the location is outside the appropriate region of the matrix. +func (s *SymBandDense) SetSymBand(i, j int, v float64) { + s.set(i, j, v) +} + +func (s *SymBandDense) set(i, j int, v float64) { + if uint(i) >= uint(s.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(s.mat.N) { + panic(ErrColAccess) + } + if i > j { + i, j = j, i + } + pj := j - i + if s.mat.K+1 <= pj { + panic(ErrBandSet) + } + s.mat.Data[i*s.mat.Stride+pj] = v +} diff --git a/vendor/gonum.org/v1/gonum/mat/index_no_bound_checks.go b/vendor/gonum.org/v1/gonum/mat/index_no_bound_checks.go new file mode 100644 index 00000000..947be6c2 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/mat/index_no_bound_checks.go @@ -0,0 +1,237 @@ +// Copyright ©2014 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file must be kept in sync with index_bound_checks.go. + +//+build !bounds + +package mat + +// At returns the element at row i, column j. +func (m *Dense) At(i, j int) float64 { + if uint(i) >= uint(m.mat.Rows) { + panic(ErrRowAccess) + } + if uint(j) >= uint(m.mat.Cols) { + panic(ErrColAccess) + } + return m.at(i, j) +} + +func (m *Dense) at(i, j int) float64 { + return m.mat.Data[i*m.mat.Stride+j] +} + +// Set sets the element at row i, column j to the value v. +func (m *Dense) Set(i, j int, v float64) { + if uint(i) >= uint(m.mat.Rows) { + panic(ErrRowAccess) + } + if uint(j) >= uint(m.mat.Cols) { + panic(ErrColAccess) + } + m.set(i, j, v) +} + +func (m *Dense) set(i, j int, v float64) { + m.mat.Data[i*m.mat.Stride+j] = v +} + +// At returns the element at row i. +// It panics if i is out of bounds or if j is not zero. +func (v *VecDense) At(i, j int) float64 { + if uint(i) >= uint(v.n) { + panic(ErrRowAccess) + } + if j != 0 { + panic(ErrColAccess) + } + return v.at(i) +} + +// AtVec returns the element at row i. +// It panics if i is out of bounds. +func (v *VecDense) AtVec(i int) float64 { + if uint(i) >= uint(v.n) { + panic(ErrRowAccess) + } + return v.at(i) +} + +func (v *VecDense) at(i int) float64 { + return v.mat.Data[i*v.mat.Inc] +} + +// SetVec sets the element at row i to the value val. +// It panics if i is out of bounds. +func (v *VecDense) SetVec(i int, val float64) { + if uint(i) >= uint(v.n) { + panic(ErrVectorAccess) + } + v.setVec(i, val) +} + +func (v *VecDense) setVec(i int, val float64) { + v.mat.Data[i*v.mat.Inc] = val +} + +// At returns the element at row i and column j. +func (s *SymDense) At(i, j int) float64 { + if uint(i) >= uint(s.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(s.mat.N) { + panic(ErrColAccess) + } + return s.at(i, j) +} + +func (s *SymDense) at(i, j int) float64 { + if i > j { + i, j = j, i + } + return s.mat.Data[i*s.mat.Stride+j] +} + +// SetSym sets the elements at (i,j) and (j,i) to the value v. +func (s *SymDense) SetSym(i, j int, v float64) { + if uint(i) >= uint(s.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(s.mat.N) { + panic(ErrColAccess) + } + s.set(i, j, v) +} + +func (s *SymDense) set(i, j int, v float64) { + if i > j { + i, j = j, i + } + s.mat.Data[i*s.mat.Stride+j] = v +} + +// At returns the element at row i, column j. +func (t *TriDense) At(i, j int) float64 { + if uint(i) >= uint(t.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(t.mat.N) { + panic(ErrColAccess) + } + return t.at(i, j) +} + +func (t *TriDense) at(i, j int) float64 { + isUpper := t.triKind() + if (isUpper && i > j) || (!isUpper && i < j) { + return 0 + } + return t.mat.Data[i*t.mat.Stride+j] +} + +// SetTri sets the element at row i, column j to the value v. +// It panics if the location is outside the appropriate half of the matrix. +func (t *TriDense) SetTri(i, j int, v float64) { + if uint(i) >= uint(t.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(t.mat.N) { + panic(ErrColAccess) + } + isUpper := t.isUpper() + if (isUpper && i > j) || (!isUpper && i < j) { + panic(ErrTriangleSet) + } + t.set(i, j, v) +} + +func (t *TriDense) set(i, j int, v float64) { + t.mat.Data[i*t.mat.Stride+j] = v +} + +// At returns the element at row i, column j. +func (b *BandDense) At(i, j int) float64 { + if uint(i) >= uint(b.mat.Rows) { + panic(ErrRowAccess) + } + if uint(j) >= uint(b.mat.Cols) { + panic(ErrColAccess) + } + return b.at(i, j) +} + +func (b *BandDense) at(i, j int) float64 { + pj := j + b.mat.KL - i + if pj < 0 || b.mat.KL+b.mat.KU+1 <= pj { + return 0 + } + return b.mat.Data[i*b.mat.Stride+pj] +} + +// SetBand sets the element at row i, column j to the value v. +// It panics if the location is outside the appropriate region of the matrix. +func (b *BandDense) SetBand(i, j int, v float64) { + if uint(i) >= uint(b.mat.Rows) { + panic(ErrRowAccess) + } + if uint(j) >= uint(b.mat.Cols) { + panic(ErrColAccess) + } + pj := j + b.mat.KL - i + if pj < 0 || b.mat.KL+b.mat.KU+1 <= pj { + panic(ErrBandSet) + } + b.set(i, j, v) +} + +func (b *BandDense) set(i, j int, v float64) { + pj := j + b.mat.KL - i + b.mat.Data[i*b.mat.Stride+pj] = v +} + +// At returns the element at row i, column j. +func (s *SymBandDense) At(i, j int) float64 { + if uint(i) >= uint(s.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(s.mat.N) { + panic(ErrColAccess) + } + return s.at(i, j) +} + +func (s *SymBandDense) at(i, j int) float64 { + if i > j { + i, j = j, i + } + pj := j - i + if s.mat.K+1 <= pj { + return 0 + } + return s.mat.Data[i*s.mat.Stride+pj] +} + +// SetSymBand sets the element at row i, column j to the value v. +// It panics if the location is outside the appropriate region of the matrix. +func (s *SymBandDense) SetSymBand(i, j int, v float64) { + if uint(i) >= uint(s.mat.N) { + panic(ErrRowAccess) + } + if uint(j) >= uint(s.mat.N) { + panic(ErrColAccess) + } + s.set(i, j, v) +} + +func (s *SymBandDense) set(i, j int, v float64) { + if i > j { + i, j = j, i + } + pj := j - i + if s.mat.K+1 <= pj { + panic(ErrBandSet) + } + s.mat.Data[i*s.mat.Stride+pj] = v +} diff --git a/vendor/gonum.org/v1/gonum/mat/inner.go b/vendor/gonum.org/v1/gonum/mat/inner.go new file mode 100644 index 00000000..fba3e0b0 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/mat/inner.go @@ -0,0 +1,121 @@ +// Copyright ©2014 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mat + +import ( + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/internal/asm/f64" +) + +// Inner computes the generalized inner product +// x^T A y +// between column vectors x and y with matrix A. This is only a true inner product if +// A is symmetric positive definite, though the operation works for any matrix A. +// +// Inner panics if x.Len != m or y.Len != n when A is an m x n matrix. +func Inner(x Vector, a Matrix, y Vector) float64 { + m, n := a.Dims() + if x.Len() != m { + panic(ErrShape) + } + if y.Len() != n { + panic(ErrShape) + } + if m == 0 || n == 0 { + return 0 + } + + var sum float64 + + switch a := a.(type) { + case RawSymmetricer: + amat := a.RawSymmetric() + if amat.Uplo != blas.Upper { + // Panic as a string not a mat.Error. + panic(badSymTriangle) + } + var xmat, ymat blas64.Vector + if xrv, ok := x.(RawVectorer); ok { + xmat = xrv.RawVector() + } else { + break + } + if yrv, ok := y.(RawVectorer); ok { + ymat = yrv.RawVector() + } else { + break + } + for i := 0; i < x.Len(); i++ { + xi := x.AtVec(i) + if xi != 0 { + if ymat.Inc == 1 { + sum += xi * f64.DotUnitary( + amat.Data[i*amat.Stride+i:i*amat.Stride+n], + ymat.Data[i:], + ) + } else { + sum += xi * f64.DotInc( + amat.Data[i*amat.Stride+i:i*amat.Stride+n], + ymat.Data[i*ymat.Inc:], uintptr(n-i), + 1, uintptr(ymat.Inc), + 0, 0, + ) + } + } + yi := y.AtVec(i) + if i != n-1 && yi != 0 { + if xmat.Inc == 1 { + sum += yi * f64.DotUnitary( + amat.Data[i*amat.Stride+i+1:i*amat.Stride+n], + xmat.Data[i+1:], + ) + } else { + sum += yi * f64.DotInc( + amat.Data[i*amat.Stride+i+1:i*amat.Stride+n], + xmat.Data[(i+1)*xmat.Inc:], uintptr(n-i-1), + 1, uintptr(xmat.Inc), + 0, 0, + ) + } + } + } + return sum + case RawMatrixer: + amat := a.RawMatrix() + var ymat blas64.Vector + if yrv, ok := y.(RawVectorer); ok { + ymat = yrv.RawVector() + } else { + break + } + for i := 0; i < x.Len(); i++ { + xi := x.AtVec(i) + if xi != 0 { + if ymat.Inc == 1 { + sum += xi * f64.DotUnitary( + amat.Data[i*amat.Stride:i*amat.Stride+n], + ymat.Data, + ) + } else { + sum += xi * f64.DotInc( + amat.Data[i*amat.Stride:i*amat.Stride+n], + ymat.Data, uintptr(n), + 1, uintptr(ymat.Inc), + 0, 0, + ) + } + } + } + return sum + } + for i := 0; i < x.Len(); i++ { + xi := x.AtVec(i) + for j := 0; j < y.Len(); j++ { + sum += xi * a.At(i, j) * y.AtVec(j) + } + } + return sum +} diff --git a/vendor/github.com/gonum/matrix/mat64/io.go b/vendor/gonum.org/v1/gonum/mat/io.go similarity index 89% rename from vendor/github.com/gonum/matrix/mat64/io.go rename to vendor/gonum.org/v1/gonum/mat/io.go index 903cdc7d..35082a2b 100644 --- a/vendor/github.com/gonum/matrix/mat64/io.go +++ b/vendor/gonum.org/v1/gonum/mat/io.go @@ -1,8 +1,8 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( "encoding/binary" @@ -20,10 +20,10 @@ var ( sizeInt64 = binary.Size(int64(0)) sizeFloat64 = binary.Size(float64(0)) - errTooBig = errors.New("mat64: resulting data slice too big") - errTooSmall = errors.New("mat64: input slice too small") - errBadBuffer = errors.New("mat64: data buffer size mismatch") - errBadSize = errors.New("mat64: invalid dimension") + errTooBig = errors.New("mat: resulting data slice too big") + errTooSmall = errors.New("mat: input slice too small") + errBadBuffer = errors.New("mat: data buffer size mismatch") + errBadSize = errors.New("mat: invalid dimension") ) // MarshalBinary encodes the receiver into a binary form and returns the result. @@ -109,8 +109,8 @@ func (m Dense) MarshalBinaryTo(w io.Writer) (int, error) { // UnmarshalBinary does not limit the size of the unmarshaled matrix, and so // it should not be used on untrusted data. func (m *Dense) UnmarshalBinary(data []byte) error { - if !m.isZero() { - panic("mat64: unmarshal into non-zero matrix") + if !m.IsZero() { + panic("mat: unmarshal into non-zero matrix") } if len(data) < 2*sizeInt64 { @@ -158,8 +158,8 @@ func (m *Dense) UnmarshalBinary(data []byte) error { // UnmarshalBinary does not limit the size of the unmarshaled matrix, and so // it should not be used on untrusted data. func (m *Dense) UnmarshalBinaryFrom(r io.Reader) (int, error) { - if !m.isZero() { - panic("mat64: unmarshal into non-zero matrix") + if !m.IsZero() { + panic("mat: unmarshal into non-zero matrix") } var ( @@ -203,10 +203,10 @@ func (m *Dense) UnmarshalBinaryFrom(r io.Reader) (int, error) { // MarshalBinary encodes the receiver into a binary form and returns the result. // -// Vector is little-endian encoded as follows: +// VecDense is little-endian encoded as follows: // 0 - 7 number of elements (int64) // 8 - .. vector's data elements (float64) -func (v Vector) MarshalBinary() ([]byte, error) { +func (v VecDense) MarshalBinary() ([]byte, error) { bufLen := int64(sizeInt64) + int64(v.n)*int64(sizeFloat64) if bufLen <= 0 { // bufLen is too big and has wrapped around. @@ -230,7 +230,7 @@ func (v Vector) MarshalBinary() ([]byte, error) { // returns the number of bytes written and an error if any. // // See MarshalBainry for the on-disk format. -func (v Vector) MarshalBinaryTo(w io.Writer) (int, error) { +func (v VecDense) MarshalBinaryTo(w io.Writer) (int, error) { var ( n int buf [8]byte @@ -256,20 +256,20 @@ func (v Vector) MarshalBinaryTo(w io.Writer) (int, error) { } // UnmarshalBinary decodes the binary form into the receiver. -// It panics if the receiver is a non-zero Vector. +// It panics if the receiver is a non-zero VecDense. // // See MarshalBinary for the on-disk layout. // // Limited checks on the validity of the binary input are performed: // - matrix.ErrShape is returned if the number of rows is negative, -// - an error is returned if the resulting Vector is too +// - an error is returned if the resulting VecDense is too // big for the current architecture (e.g. a 16GB vector written by a // 64b application and read back from a 32b application.) // UnmarshalBinary does not limit the size of the unmarshaled vector, and so // it should not be used on untrusted data. -func (v *Vector) UnmarshalBinary(data []byte) error { - if !v.isZero() { - panic("mat64: unmarshal into non-zero vector") +func (v *VecDense) UnmarshalBinary(data []byte) error { + if !v.IsZero() { + panic("mat: unmarshal into non-zero vector") } p := 0 @@ -296,13 +296,13 @@ func (v *Vector) UnmarshalBinary(data []byte) error { // UnmarshalBinaryFrom decodes the binary form into the receiver, from the // io.Reader and returns the number of bytes read and an error if any. -// It panics if the receiver is a non-zero Vector. +// It panics if the receiver is a non-zero VecDense. // // See MarshalBinary for the on-disk layout. // See UnmarshalBinary for the list of sanity checks performed on the input. -func (v *Vector) UnmarshalBinaryFrom(r io.Reader) (int, error) { - if !v.isZero() { - panic("mat64: unmarshal into non-zero vector") +func (v *VecDense) UnmarshalBinaryFrom(r io.Reader) (int, error) { + if !v.IsZero() { + panic("mat: unmarshal into non-zero vector") } var ( diff --git a/vendor/gonum.org/v1/gonum/mat/lq.go b/vendor/gonum.org/v1/gonum/mat/lq.go new file mode 100644 index 00000000..cbb906f3 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/mat/lq.go @@ -0,0 +1,235 @@ +// Copyright ©2013 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mat + +import ( + "math" + + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" + "gonum.org/v1/gonum/lapack/lapack64" +) + +// LQ is a type for creating and using the LQ factorization of a matrix. +type LQ struct { + lq *Dense + tau []float64 + cond float64 +} + +func (lq *LQ) updateCond(norm lapack.MatrixNorm) { + // Since A = L*Q, and Q is orthogonal, we get for the condition number κ + // κ(A) := |A| |A^-1| = |L*Q| |(L*Q)^-1| = |L| |Q^T * L^-1| + // = |L| |L^-1| = κ(L), + // where we used that fact that Q^-1 = Q^T. However, this assumes that + // the matrix norm is invariant under orthogonal transformations which + // is not the case for CondNorm. Hopefully the error is negligible: κ + // is only a qualitative measure anyway. + m := lq.lq.mat.Rows + work := getFloats(3*m, false) + iwork := getInts(m, false) + l := lq.lq.asTriDense(m, blas.NonUnit, blas.Lower) + v := lapack64.Trcon(norm, l.mat, work, iwork) + lq.cond = 1 / v + putFloats(work) + putInts(iwork) +} + +// Factorize computes the LQ factorization of an m×n matrix a where n <= m. The LQ +// factorization always exists even if A is singular. +// +// The LQ decomposition is a factorization of the matrix A such that A = L * Q. +// The matrix Q is an orthonormal n×n matrix, and L is an m×n upper triangular matrix. +// L and Q can be extracted from the LTo and QTo methods. +func (lq *LQ) Factorize(a Matrix) { + lq.factorize(a, CondNorm) +} + +func (lq *LQ) factorize(a Matrix, norm lapack.MatrixNorm) { + m, n := a.Dims() + if m > n { + panic(ErrShape) + } + k := min(m, n) + if lq.lq == nil { + lq.lq = &Dense{} + } + lq.lq.Clone(a) + work := []float64{0} + lq.tau = make([]float64, k) + lapack64.Gelqf(lq.lq.mat, lq.tau, work, -1) + work = getFloats(int(work[0]), false) + lapack64.Gelqf(lq.lq.mat, lq.tau, work, len(work)) + putFloats(work) + lq.updateCond(norm) +} + +// Cond returns the condition number for the factorized matrix. +// Cond will panic if the receiver does not contain a successful factorization. +func (lq *LQ) Cond() float64 { + if lq.lq == nil || lq.lq.IsZero() { + panic("lq: no decomposition computed") + } + return lq.cond +} + +// TODO(btracey): Add in the "Reduced" forms for extracting the m×m orthogonal +// and upper triangular matrices. + +// LTo extracts the m×n lower trapezoidal matrix from a LQ decomposition. +// If dst is nil, a new matrix is allocated. The resulting L matrix is returned. +func (lq *LQ) LTo(dst *Dense) *Dense { + r, c := lq.lq.Dims() + if dst == nil { + dst = NewDense(r, c, nil) + } else { + dst.reuseAs(r, c) + } + + // Disguise the LQ as a lower triangular. + t := &TriDense{ + mat: blas64.Triangular{ + N: r, + Stride: lq.lq.mat.Stride, + Data: lq.lq.mat.Data, + Uplo: blas.Lower, + Diag: blas.NonUnit, + }, + cap: lq.lq.capCols, + } + dst.Copy(t) + + if r == c { + return dst + } + // Zero right of the triangular. + for i := 0; i < r; i++ { + zero(dst.mat.Data[i*dst.mat.Stride+r : i*dst.mat.Stride+c]) + } + + return dst +} + +// QTo extracts the n×n orthonormal matrix Q from an LQ decomposition. +// If dst is nil, a new matrix is allocated. The resulting Q matrix is returned. +func (lq *LQ) QTo(dst *Dense) *Dense { + _, c := lq.lq.Dims() + if dst == nil { + dst = NewDense(c, c, nil) + } else { + dst.reuseAsZeroed(c, c) + } + q := dst.mat + + // Set Q = I. + ldq := q.Stride + for i := 0; i < c; i++ { + q.Data[i*ldq+i] = 1 + } + + // Construct Q from the elementary reflectors. + work := []float64{0} + lapack64.Ormlq(blas.Left, blas.NoTrans, lq.lq.mat, lq.tau, q, work, -1) + work = getFloats(int(work[0]), false) + lapack64.Ormlq(blas.Left, blas.NoTrans, lq.lq.mat, lq.tau, q, work, len(work)) + putFloats(work) + + return dst +} + +// Solve finds a minimum-norm solution to a system of linear equations defined +// by the matrices A and b, where A is an m×n matrix represented in its LQ factorized +// form. If A is singular or near-singular a Condition error is returned. +// See the documentation for Condition for more information. +// +// The minimization problem solved depends on the input parameters. +// If trans == false, find the minimum norm solution of A * X = b. +// If trans == true, find X such that ||A*X - b||_2 is minimized. +// The solution matrix, X, is stored in place into m. +func (lq *LQ) Solve(m *Dense, trans bool, b Matrix) error { + r, c := lq.lq.Dims() + br, bc := b.Dims() + + // The LQ solve algorithm stores the result in-place into the right hand side. + // The storage for the answer must be large enough to hold both b and x. + // However, this method's receiver must be the size of x. Copy b, and then + // copy the result into m at the end. + if trans { + if c != br { + panic(ErrShape) + } + m.reuseAs(r, bc) + } else { + if r != br { + panic(ErrShape) + } + m.reuseAs(c, bc) + } + // Do not need to worry about overlap between m and b because x has its own + // independent storage. + x := getWorkspace(max(r, c), bc, false) + x.Copy(b) + t := lq.lq.asTriDense(lq.lq.mat.Rows, blas.NonUnit, blas.Lower).mat + if trans { + work := []float64{0} + lapack64.Ormlq(blas.Left, blas.NoTrans, lq.lq.mat, lq.tau, x.mat, work, -1) + work = getFloats(int(work[0]), false) + lapack64.Ormlq(blas.Left, blas.NoTrans, lq.lq.mat, lq.tau, x.mat, work, len(work)) + putFloats(work) + + ok := lapack64.Trtrs(blas.Trans, t, x.mat) + if !ok { + return Condition(math.Inf(1)) + } + } else { + ok := lapack64.Trtrs(blas.NoTrans, t, x.mat) + if !ok { + return Condition(math.Inf(1)) + } + for i := r; i < c; i++ { + zero(x.mat.Data[i*x.mat.Stride : i*x.mat.Stride+bc]) + } + work := []float64{0} + lapack64.Ormlq(blas.Left, blas.Trans, lq.lq.mat, lq.tau, x.mat, work, -1) + work = getFloats(int(work[0]), false) + lapack64.Ormlq(blas.Left, blas.Trans, lq.lq.mat, lq.tau, x.mat, work, len(work)) + putFloats(work) + } + // M was set above to be the correct size for the result. + m.Copy(x) + putWorkspace(x) + if lq.cond > ConditionTolerance { + return Condition(lq.cond) + } + return nil +} + +// SolveVec finds a minimum-norm solution to a system of linear equations. +// See LQ.Solve for the full documentation. +func (lq *LQ) SolveVec(v *VecDense, trans bool, b Vector) error { + r, c := lq.lq.Dims() + if _, bc := b.Dims(); bc != 1 { + panic(ErrShape) + } + + // The Solve implementation is non-trivial, so rather than duplicate the code, + // instead recast the VecDenses as Dense and call the matrix code. + bm := Matrix(b) + if rv, ok := b.(RawVectorer); ok { + bmat := rv.RawVector() + if v != b { + v.checkOverlap(bmat) + } + b := VecDense{mat: bmat, n: b.Len()} + bm = b.asDense() + } + if trans { + v.reuseAs(r) + } else { + v.reuseAs(c) + } + return lq.Solve(v.asDense(), trans, bm) +} diff --git a/vendor/github.com/gonum/matrix/mat64/lu.go b/vendor/gonum.org/v1/gonum/mat/lu.go similarity index 62% rename from vendor/github.com/gonum/matrix/mat64/lu.go rename to vendor/gonum.org/v1/gonum/mat/lu.go index 6115b005..dbe8cce1 100644 --- a/vendor/github.com/gonum/matrix/mat64/lu.go +++ b/vendor/gonum.org/v1/gonum/mat/lu.go @@ -1,20 +1,20 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. +// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/floats" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/floats" + "gonum.org/v1/gonum/lapack" + "gonum.org/v1/gonum/lapack/lapack64" ) -const badSliceLength = "mat64: improper slice length" +const badSliceLength = "mat: improper slice length" // LU is a type for creating and using the LU factorization of a matrix. type LU struct { @@ -23,25 +23,29 @@ type LU struct { cond float64 } -// updateCond updates the stored condition number of the matrix. Norm is the -// norm of the original matrix. If norm is negative it will be estimated. -func (lu *LU) updateCond(norm float64) { +// updateCond updates the stored condition number of the matrix. anorm is the +// norm of the original matrix. If anorm is negative it will be estimated. +func (lu *LU) updateCond(anorm float64, norm lapack.MatrixNorm) { n := lu.lu.mat.Cols - work := make([]float64, 4*n) - iwork := make([]int, n) - if norm < 0 { - // This is an approximation. By the definition of a norm, ||AB|| <= ||A|| ||B||. - // The condition number is ||A|| || A^-1||, so this will underestimate - // the condition number somewhat. - // The norm of the original factorized matrix cannot be stored because of - // update possibilities, e.g. RankOne. + work := getFloats(4*n, false) + defer putFloats(work) + iwork := getInts(n, false) + defer putInts(iwork) + if anorm < 0 { + // This is an approximation. By the definition of a norm, + // |AB| <= |A| |B|. + // Since A = L*U, we get for the condition number κ that + // κ(A) := |A| |A^-1| = |L*U| |A^-1| <= |L| |U| |A^-1|, + // so this will overestimate the condition number somewhat. + // The norm of the original factorized matrix cannot be stored + // because of update possibilities. u := lu.lu.asTriDense(n, blas.NonUnit, blas.Upper) l := lu.lu.asTriDense(n, blas.Unit, blas.Lower) - unorm := lapack64.Lantr(matrix.CondNorm, u.mat, work) - lnorm := lapack64.Lantr(matrix.CondNorm, l.mat, work) - norm = unorm * lnorm + unorm := lapack64.Lantr(norm, u.mat, work) + lnorm := lapack64.Lantr(norm, l.mat, work) + anorm = unorm * lnorm } - v := lapack64.Gecon(matrix.CondNorm, lu.lu.mat, norm, work, iwork) + v := lapack64.Gecon(norm, lu.lu.mat, anorm, work, iwork) lu.cond = 1 / v } @@ -51,11 +55,15 @@ func (lu *LU) updateCond(norm float64) { // The LU factorization is computed with pivoting, and so really the decomposition // is a PLU decomposition where P is a permutation matrix. The individual matrix // factors can be extracted from the factorization using the Permutation method -// on Dense, and the LFrom and UFrom methods on TriDense. +// on Dense, and the LU LTo and UTo methods. func (lu *LU) Factorize(a Matrix) { + lu.factorize(a, CondNorm) +} + +func (lu *LU) factorize(a Matrix, norm lapack.MatrixNorm) { r, c := a.Dims() if r != c { - panic(matrix.ErrSquare) + panic(ErrSquare) } if lu.lu == nil { lu.lu = NewDense(r, r, nil) @@ -68,10 +76,20 @@ func (lu *LU) Factorize(a Matrix) { lu.pivot = make([]int, r) } lu.pivot = lu.pivot[:r] - work := make([]float64, r) - anorm := lapack64.Lange(matrix.CondNorm, lu.lu.mat, work) + work := getFloats(r, false) + anorm := lapack64.Lange(norm, lu.lu.mat, work) + putFloats(work) lapack64.Getrf(lu.lu.mat, lu.pivot) - lu.updateCond(anorm) + lu.updateCond(anorm, norm) +} + +// Cond returns the condition number for the factorized matrix. +// Cond will panic if the receiver does not contain a successful factorization. +func (lu *LU) Cond() float64 { + if lu.lu == nil || lu.lu.IsZero() { + panic("lu: no decomposition computed") + } + return lu.cond } // Reset resets the factorization so that it can be reused as the receiver of a @@ -99,7 +117,8 @@ func (lu *LU) Det() float64 { // division expressions is generally improved by working in log space. func (lu *LU) LogDet() (det float64, sign float64) { _, n := lu.lu.Dims() - logDiag := make([]float64, n) + logDiag := getFloats(n, false) + defer putFloats(logDiag) sign = 1.0 for i := 0; i < n; i++ { v := lu.lu.at(i, i) @@ -142,16 +161,16 @@ func (lu *LU) Pivot(swaps []int) []int { // the original matrix A, storing the result into the receiver. That is, if in // the original LU decomposition P * L * U = A, in the updated decomposition // P * L * U = A + alpha * x * y^T. -func (lu *LU) RankOne(orig *LU, alpha float64, x, y *Vector) { +func (lu *LU) RankOne(orig *LU, alpha float64, x, y *VecDense) { // RankOne uses algorithm a1 on page 28 of "Multiple-Rank Updates to Matrix // Factorizations for Nonlinear Analysis and Circuit Design" by Linzhong Deng. // http://web.stanford.edu/group/SOL/dissertations/Linzhong-Deng-thesis.pdf _, n := orig.lu.Dims() if x.Len() != n { - panic(matrix.ErrShape) + panic(ErrShape) } if y.Len() != n { - panic(matrix.ErrShape) + panic(ErrShape) } if orig != lu { if lu.isZero() { @@ -165,14 +184,16 @@ func (lu *LU) RankOne(orig *LU, alpha float64, x, y *Vector) { lu.lu.reuseAs(n, n) } } else if len(lu.pivot) != n { - panic(matrix.ErrShape) + panic(ErrShape) } copy(lu.pivot, orig.pivot) lu.lu.Copy(orig.lu) } - xs := make([]float64, n) - ys := make([]float64, n) + xs := getFloats(n, false) + defer putFloats(xs) + ys := getFloats(n, false) + defer putFloats(ys) for i := 0; i < n; i++ { xs[i] = x.at(i) ys[i] = y.at(i) @@ -201,35 +222,47 @@ func (lu *LU) RankOne(orig *LU, alpha float64, x, y *Vector) { lum.Data[j*lum.Stride+i] += gamma * tmp } } - lu.updateCond(-1) + lu.updateCond(-1, CondNorm) } -// LFromLU extracts the lower triangular matrix from an LU factorization. -func (t *TriDense) LFromLU(lu *LU) { +// LTo extracts the lower triangular matrix from an LU factorization. +// If dst is nil, a new matrix is allocated. The resulting L matrix is returned. +func (lu *LU) LTo(dst *TriDense) *TriDense { _, n := lu.lu.Dims() - t.reuseAs(n, false) + if dst == nil { + dst = NewTriDense(n, Lower, nil) + } else { + dst.reuseAs(n, Lower) + } // Extract the lower triangular elements. for i := 0; i < n; i++ { for j := 0; j < i; j++ { - t.mat.Data[i*t.mat.Stride+j] = lu.lu.mat.Data[i*lu.lu.mat.Stride+j] + dst.mat.Data[i*dst.mat.Stride+j] = lu.lu.mat.Data[i*lu.lu.mat.Stride+j] } } // Set ones on the diagonal. for i := 0; i < n; i++ { - t.mat.Data[i*t.mat.Stride+i] = 1 + dst.mat.Data[i*dst.mat.Stride+i] = 1 } + return dst } -// UFromLU extracts the upper triangular matrix from an LU factorization. -func (t *TriDense) UFromLU(lu *LU) { +// UTo extracts the upper triangular matrix from an LU factorization. +// If dst is nil, a new matrix is allocated. The resulting U matrix is returned. +func (lu *LU) UTo(dst *TriDense) *TriDense { _, n := lu.lu.Dims() - t.reuseAs(n, true) + if dst == nil { + dst = NewTriDense(n, Upper, nil) + } else { + dst.reuseAs(n, Upper) + } // Extract the upper triangular elements. for i := 0; i < n; i++ { for j := i; j < n; j++ { - t.mat.Data[i*t.mat.Stride+j] = lu.lu.mat.Data[i*lu.lu.mat.Stride+j] + dst.mat.Data[i*dst.mat.Stride+j] = lu.lu.mat.Data[i*lu.lu.mat.Stride+j] } } + return dst } // Permutation constructs an r×r permutation matrix with the given row swaps. @@ -242,31 +275,31 @@ func (m *Dense) Permutation(r int, swaps []int) { zero(m.mat.Data[i*m.mat.Stride : i*m.mat.Stride+r]) v := swaps[i] if v < 0 || v >= r { - panic(matrix.ErrRowAccess) + panic(ErrRowAccess) } m.mat.Data[i*m.mat.Stride+v] = 1 } } -// SolveLU solves a system of linear equations using the LU decomposition of a matrix. +// Solve solves a system of linear equations using the LU decomposition of a matrix. // It computes // A * x = b if trans == false // A^T * x = b if trans == true // In both cases, A is represented in LU factorized form, and the matrix x is -// stored into the receiver. +// stored into m. // -// If A is singular or near-singular a Condition error is returned. Please see +// If A is singular or near-singular a Condition error is returned. See // the documentation for Condition for more information. -func (m *Dense) SolveLU(lu *LU, trans bool, b Matrix) error { +func (lu *LU) Solve(m *Dense, trans bool, b Matrix) error { _, n := lu.lu.Dims() br, bc := b.Dims() if br != n { - panic(matrix.ErrShape) + panic(ErrShape) } // TODO(btracey): Should test the condition number instead of testing that // the determinant is exactly zero. if lu.Det() == 0 { - return matrix.Condition(math.Inf(1)) + return Condition(math.Inf(1)) } m.reuseAs(n, bc) @@ -285,56 +318,61 @@ func (m *Dense) SolveLU(lu *LU, trans bool, b Matrix) error { t = blas.Trans } lapack64.Getrs(t, lu.lu.mat, m.mat, lu.pivot) - if lu.cond > matrix.ConditionTolerance { - return matrix.Condition(lu.cond) + if lu.cond > ConditionTolerance { + return Condition(lu.cond) } return nil } -// SolveLUVec solves a system of linear equations using the LU decomposition of a matrix. +// SolveVec solves a system of linear equations using the LU decomposition of a matrix. // It computes // A * x = b if trans == false // A^T * x = b if trans == true // In both cases, A is represented in LU factorized form, and the matrix x is -// stored into the receiver. +// stored into v. // -// If A is singular or near-singular a Condition error is returned. Please see +// If A is singular or near-singular a Condition error is returned. See // the documentation for Condition for more information. -func (v *Vector) SolveLUVec(lu *LU, trans bool, b *Vector) error { +func (lu *LU) SolveVec(v *VecDense, trans bool, b Vector) error { _, n := lu.lu.Dims() - bn := b.Len() - if bn != n { - panic(matrix.ErrShape) - } - if v != b { - v.checkOverlap(b.mat) - } - // TODO(btracey): Should test the condition number instead of testing that - // the determinant is exactly zero. - if lu.Det() == 0 { - return matrix.Condition(math.Inf(1)) + if br, bc := b.Dims(); br != n || bc != 1 { + panic(ErrShape) } + switch rv := b.(type) { + default: + v.reuseAs(n) + return lu.Solve(v.asDense(), trans, b) + case RawVectorer: + if v != b { + v.checkOverlap(rv.RawVector()) + } + // TODO(btracey): Should test the condition number instead of testing that + // the determinant is exactly zero. + if lu.Det() == 0 { + return Condition(math.Inf(1)) + } - v.reuseAs(n) - var restore func() - if v == b { - v, restore = v.isolatedWorkspace(b) - defer restore() + v.reuseAs(n) + var restore func() + if v == b { + v, restore = v.isolatedWorkspace(b) + defer restore() + } + v.CopyVec(b) + vMat := blas64.General{ + Rows: n, + Cols: 1, + Stride: v.mat.Inc, + Data: v.mat.Data, + } + t := blas.NoTrans + if trans { + t = blas.Trans + } + lapack64.Getrs(t, lu.lu.mat, vMat, lu.pivot) + if lu.cond > ConditionTolerance { + return Condition(lu.cond) + } + return nil } - v.CopyVec(b) - vMat := blas64.General{ - Rows: n, - Cols: 1, - Stride: v.mat.Inc, - Data: v.mat.Data, - } - t := blas.NoTrans - if trans { - t = blas.Trans - } - lapack64.Getrs(t, lu.lu.mat, vMat, lu.pivot) - if lu.cond > matrix.ConditionTolerance { - return matrix.Condition(lu.cond) - } - return nil } diff --git a/vendor/github.com/gonum/matrix/mat64/matrix.go b/vendor/gonum.org/v1/gonum/mat/matrix.go similarity index 88% rename from vendor/github.com/gonum/matrix/mat64/matrix.go rename to vendor/gonum.org/v1/gonum/mat/matrix.go index 4b33b7c8..59f94583 100644 --- a/vendor/github.com/gonum/matrix/mat64/matrix.go +++ b/vendor/gonum.org/v1/gonum/mat/matrix.go @@ -1,18 +1,17 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. +// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/floats" - "github.com/gonum/lapack" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/floats" + "gonum.org/v1/gonum/lapack" + "gonum.org/v1/gonum/lapack/lapack64" ) // Matrix is the basic matrix interface type. @@ -69,7 +68,7 @@ func (t Transpose) Untranspose() Matrix { // Untransposer is a type that can undo an implicit transpose. type Untransposer interface { // Note: This interface is needed to unify all of the Transpose types. In - // the mat64 methods, we need to test if the Matrix has been implicitly + // the mat methods, we need to test if the Matrix has been implicitly // transposed. If this is checked by testing for the specific Transpose type // then the behavior will be different if the user uses T() or TTri() for a // triangular matrix. @@ -78,6 +77,12 @@ type Untransposer interface { Untranspose() Matrix } +// UntransposeBander is a type that can undo an implicit band transpose. +type UntransposeBander interface { + // Untranspose returns the underlying Banded stored for the implicit transpose. + UntransposeBand() Banded +} + // UntransposeTrier is a type that can undo an implicit triangular transpose. type UntransposeTrier interface { // Untranspose returns the underlying Triangular stored for the implicit transpose. @@ -96,7 +101,7 @@ type Mutable interface { // A RowViewer can return a Vector reflecting a row that is backed by the matrix // data. The Vector returned will have length equal to the number of columns. type RowViewer interface { - RowView(i int) *Vector + RowView(i int) Vector } // A RawRowViewer can return a slice of float64 reflecting a row that is backed by the matrix @@ -108,7 +113,7 @@ type RawRowViewer interface { // A ColViewer can return a Vector reflecting a column that is backed by the matrix // data. The Vector returned will have length equal to the number of rows. type ColViewer interface { - ColView(j int) *Vector + ColView(j int) Vector } // A RawColViewer can return a slice of float64 reflecting a column that is backed by the matrix @@ -144,15 +149,6 @@ type Copier interface { Copy(a Matrix) (r, c int) } -// A Viewer returns a submatrix view of the Matrix parameter, starting at row i, column j -// and extending r rows and c columns. If i or j are out of range, or r or c are zero or -// extend beyond the bounds of the matrix View will panic with ErrIndexOutOfRange. The -// returned matrix must retain the receiver's reference to the original matrix such that -// changes in the elements of the submatrix are reflected in the original and vice versa. -type Viewer interface { - View(i, j, r, c int) Matrix -} - // A Grower can grow the size of the represented matrix by the given number of rows and columns. // Growing beyond the size given by the Caps method will result in the allocation of a new // matrix and copying of the elements. If Grow is called with negative increments it will @@ -186,6 +182,24 @@ type RawVectorer interface { RawVector() blas64.Vector } +// A NonZeroDoer can call a function for each non-zero element of the receiver. +// The parameters of the function are the element indices and its value. +type NonZeroDoer interface { + DoNonZero(func(i, j int, v float64)) +} + +// A RowNonZeroDoer can call a function for each non-zero element of a row of the receiver. +// The parameters of the function are the element indices and its value. +type RowNonZeroDoer interface { + DoRowNonZero(i int, fn func(i, j int, v float64)) +} + +// A ColNonZeroDoer can call a function for each non-zero element of a column of the receiver. +// The parameters of the function are the element indices and its value. +type ColNonZeroDoer interface { + DoColNonZero(j int, fn func(i, j int, v float64)) +} + // TODO(btracey): Consider adding CopyCol/CopyRow if the behavior seems useful. // TODO(btracey): Add in fast paths to Row/Col for the other concrete types // (TriDense, etc.) as well as relevant interfaces (RowColer, RawRowViewer, etc.) @@ -196,13 +210,13 @@ type RawVectorer interface { func Col(dst []float64, j int, a Matrix) []float64 { r, c := a.Dims() if j < 0 || j >= c { - panic(matrix.ErrColAccess) + panic(ErrColAccess) } if dst == nil { dst = make([]float64, r) } else { if len(dst) != r { - panic(matrix.ErrColLength) + panic(ErrColLength) } } aU, aTrans := untranspose(a) @@ -224,19 +238,19 @@ func Col(dst []float64, j int, a Matrix) []float64 { return dst } -// Row copies the elements in the jth column of the matrix into the slice dst. +// Row copies the elements in the ith row of the matrix into the slice dst. // The length of the provided slice must equal the number of columns, unless the // slice is nil in which case a new slice is first allocated. func Row(dst []float64, i int, a Matrix) []float64 { r, c := a.Dims() if i < 0 || i >= r { - panic(matrix.ErrColAccess) + panic(ErrColAccess) } if dst == nil { dst = make([]float64, c) } else { if len(dst) != c { - panic(matrix.ErrRowLength) + panic(ErrRowLength) } } aU, aTrans := untranspose(a) @@ -270,17 +284,17 @@ func Row(dst []float64, i int, a Matrix) []float64 { func Cond(a Matrix, norm float64) float64 { m, n := a.Dims() if m == 0 || n == 0 { - panic(matrix.ErrShape) + panic(ErrShape) } var lnorm lapack.MatrixNorm switch norm { default: - panic("mat64: bad norm value") + panic("mat: bad norm value") case 1: lnorm = lapack.MaxColumnSum case 2: var svd SVD - ok := svd.Factorize(a, matrix.SVDNone) + ok := svd.Factorize(a, SVDNone) if !ok { return math.Inf(1) } @@ -288,53 +302,23 @@ func Cond(a Matrix, norm float64) float64 { case math.Inf(1): lnorm = lapack.MaxRowSum } + if m == n { // Use the LU decomposition to compute the condition number. - tmp := getWorkspace(m, n, false) - tmp.Copy(a) - work := make([]float64, 4*n) - aNorm := lapack64.Lange(lnorm, tmp.mat, work) - pivot := make([]int, m) - lapack64.Getrf(tmp.mat, pivot) - iwork := make([]int, n) - v := lapack64.Gecon(lnorm, tmp.mat, aNorm, work, iwork) - putWorkspace(tmp) - return 1 / v + var lu LU + lu.factorize(a, lnorm) + return lu.Cond() } if m > n { // Use the QR factorization to compute the condition number. - tmp := getWorkspace(m, n, false) - tmp.Copy(a) - work := make([]float64, 3*n) - tau := make([]float64, min(m, n)) - lapack64.Geqrf(tmp.mat, tau, work, -1) - if int(work[0]) > len(work) { - work = make([]float64, int(work[0])) - } - lapack64.Geqrf(tmp.mat, tau, work, len(work)) - - iwork := make([]int, n) - r := tmp.asTriDense(n, blas.NonUnit, blas.Upper) - v := lapack64.Trcon(lnorm, r.mat, work, iwork) - putWorkspace(tmp) - return 1 / v + var qr QR + qr.factorize(a, lnorm) + return qr.Cond() } // Use the LQ factorization to compute the condition number. - tmp := getWorkspace(m, n, false) - tmp.Copy(a) - work := make([]float64, 3*m) - tau := make([]float64, min(m, n)) - lapack64.Gelqf(tmp.mat, tau, work, -1) - if int(work[0]) > len(work) { - work = make([]float64, int(work[0])) - } - lapack64.Gelqf(tmp.mat, tau, work, len(work)) - - iwork := make([]int, m) - l := tmp.asTriDense(m, blas.NonUnit, blas.Lower) - v := lapack64.Trcon(lnorm, l.mat, work, iwork) - putWorkspace(tmp) - return 1 / v + var lq LQ + lq.factorize(a, lnorm) + return lq.Cond() } // Det returns the determinant of the matrix a. In many expressions using LogDet @@ -346,13 +330,22 @@ func Det(a Matrix) float64 { // Dot returns the sum of the element-wise product of a and b. // Dot panics if the matrix sizes are unequal. -func Dot(a, b *Vector) float64 { +func Dot(a, b Vector) float64 { la := a.Len() lb := b.Len() if la != lb { - panic(matrix.ErrShape) + panic(ErrShape) } - return blas64.Dot(la, a.mat, b.mat) + if arv, ok := a.(RawVectorer); ok { + if brv, ok := b.(RawVectorer); ok { + return blas64.Dot(la, arv.RawVector(), brv.RawVector()) + } + } + var sum float64 + for i := 0; i < la; i++ { + sum += a.At(i, 0) * b.At(i, 0) + } + return sum } // Equal returns whether the matrices a and b have the same size @@ -404,8 +397,8 @@ func Equal(a, b Matrix) bool { return true } } - if ra, ok := aU.(*Vector); ok { - if rb, ok := bU.(*Vector); ok { + if ra, ok := aU.(*VecDense); ok { + if rb, ok := bU.(*VecDense); ok { // If the raw vectors are the same length they must either both be // transposed or both not transposed (or have length 1). for i := 0; i < ra.n; i++ { @@ -476,8 +469,8 @@ func EqualApprox(a, b Matrix, epsilon float64) bool { return true } } - if ra, ok := aU.(*Vector); ok { - if rb, ok := bU.(*Vector); ok { + if ra, ok := aU.(*VecDense); ok { + if rb, ok := bU.(*VecDense); ok { // If the raw vectors are the same length they must either both be // transposed or both not transposed (or have length 1). for i := 0; i < ra.n; i++ { @@ -513,7 +506,7 @@ func LogDet(a Matrix) (det float64, sign float64) { func Max(a Matrix) float64 { r, c := a.Dims() if r == 0 || c == 0 { - panic(matrix.ErrShape) + panic(ErrShape) } // Max(A) = Max(A^T) aU, _ := untranspose(a) @@ -588,7 +581,7 @@ func Max(a Matrix) float64 { func Min(a Matrix) float64 { r, c := a.Dims() if r == 0 || c == 0 { - panic(matrix.ErrShape) + panic(ErrShape) } // Min(A) = Min(A^T) aU, _ := untranspose(a) @@ -670,7 +663,7 @@ func Min(a Matrix) float64 { func Norm(a Matrix, norm float64) float64 { r, c := a.Dims() if r == 0 || c == 0 { - panic(matrix.ErrShape) + panic(ErrShape) } aU, aTrans := untranspose(a) var work []float64 @@ -679,24 +672,27 @@ func Norm(a Matrix, norm float64) float64 { rm := rma.RawMatrix() n := normLapack(norm, aTrans) if n == lapack.MaxColumnSum { - work = make([]float64, rm.Cols) + work = getFloats(rm.Cols, false) + defer putFloats(work) } return lapack64.Lange(n, rm, work) case RawTriangular: rm := rma.RawTriangular() n := normLapack(norm, aTrans) if n == lapack.MaxRowSum || n == lapack.MaxColumnSum { - work = make([]float64, rm.N) + work = getFloats(rm.N, false) + defer putFloats(work) } return lapack64.Lantr(n, rm, work) case RawSymmetricer: rm := rma.RawSymmetric() n := normLapack(norm, aTrans) if n == lapack.MaxRowSum || n == lapack.MaxColumnSum { - work = make([]float64, rm.N) + work = getFloats(rm.N, false) + defer putFloats(work) } return lapack64.Lansy(n, rm, work) - case *Vector: + case *VecDense: rv := rma.RawVector() switch norm { default: @@ -774,7 +770,7 @@ func normLapack(norm float64, aTrans bool) lapack.MatrixNorm { } return n default: - panic(matrix.ErrNormOrder) + panic(ErrNormOrder) } } @@ -807,7 +803,7 @@ func Sum(a Matrix) float64 { func Trace(a Matrix) float64 { r, c := a.Dims() if r != c { - panic(matrix.ErrSquare) + panic(ErrSquare) } aU, _ := untranspose(a) diff --git a/vendor/github.com/gonum/matrix/mat64/offset.go b/vendor/gonum.org/v1/gonum/mat/offset.go similarity index 88% rename from vendor/github.com/gonum/matrix/mat64/offset.go rename to vendor/gonum.org/v1/gonum/mat/offset.go index 45707f15..7341cc0c 100644 --- a/vendor/github.com/gonum/matrix/mat64/offset.go +++ b/vendor/gonum.org/v1/gonum/mat/offset.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //+build !appengine -package mat64 +package mat import "unsafe" diff --git a/vendor/github.com/gonum/matrix/mat64/offset_appengine.go b/vendor/gonum.org/v1/gonum/mat/offset_appengine.go similarity index 89% rename from vendor/github.com/gonum/matrix/mat64/offset_appengine.go rename to vendor/gonum.org/v1/gonum/mat/offset_appengine.go index 584ef8bb..b731786d 100644 --- a/vendor/github.com/gonum/matrix/mat64/offset_appengine.go +++ b/vendor/gonum.org/v1/gonum/mat/offset_appengine.go @@ -1,10 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //+build appengine -package mat64 +package mat import "reflect" diff --git a/vendor/github.com/gonum/matrix/mat64/pool.go b/vendor/gonum.org/v1/gonum/mat/pool.go similarity index 57% rename from vendor/github.com/gonum/matrix/mat64/pool.go rename to vendor/gonum.org/v1/gonum/mat/pool.go index f296f3da..065fd542 100644 --- a/vendor/github.com/gonum/matrix/mat64/pool.go +++ b/vendor/gonum.org/v1/gonum/mat/pool.go @@ -1,15 +1,14 @@ -// Copyright ©2014 The gonum Authors. All rights reserved. +// Copyright ©2014 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( "sync" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) var tab64 = [64]byte{ @@ -52,8 +51,14 @@ var ( // poolTri is the TriDense equivalent of pool. poolTri [63]sync.Pool - // poolVec is the Vector equivalent of pool. + // poolVec is the VecDense equivalent of pool. poolVec [63]sync.Pool + + // poolFloats is the []float64 equivalent of pool. + poolFloats [63]sync.Pool + + // poolInts is the []int equivalent of pool. + poolInts [63]sync.Pool ) func init() { @@ -76,11 +81,17 @@ func init() { }} } poolVec[i].New = func() interface{} { - return &Vector{mat: blas64.Vector{ + return &VecDense{mat: blas64.Vector{ Inc: 1, Data: make([]float64, l), }} } + poolFloats[i].New = func() interface{} { + return make([]float64, l) + } + poolInts[i].New = func() interface{} { + return make([]int, l) + } } } @@ -104,13 +115,14 @@ func getWorkspace(r, c int, clear bool) *Dense { // putWorkspace replaces a used *Dense into the appropriate size // workspace pool. putWorkspace must not be called with a matrix -// where references to the underlying data slice has been kept. +// where references to the underlying data slice have been kept. func putWorkspace(w *Dense) { pool[bits(uint64(cap(w.mat.Data)))].Put(w) } -// getWorkspaceSym returns a *SymDense of size n and a cap that is less than 2*n. If clear is true, the -// data slice visible through the Matrix interface is zeroed. +// getWorkspaceSym returns a *SymDense of size n and a cap that +// is less than 2*n. If clear is true, the data slice visible +// through the Matrix interface is zeroed. func getWorkspaceSym(n int, clear bool) *SymDense { l := uint64(n) l *= l @@ -125,9 +137,17 @@ func getWorkspaceSym(n int, clear bool) *SymDense { return s } -// getWorkspaceTri returns a *TriDense of size n and a cap that is less than 2*n. -// If clear is true, the data slice visible through the Matrix interface is zeroed. -func getWorkspaceTri(n int, kind matrix.TriKind, clear bool) *TriDense { +// putWorkspaceSym replaces a used *SymDense into the appropriate size +// workspace pool. putWorkspaceSym must not be called with a matrix +// where references to the underlying data slice have been kept. +func putWorkspaceSym(s *SymDense) { + poolSym[bits(uint64(cap(s.mat.Data)))].Put(s) +} + +// getWorkspaceTri returns a *TriDense of size n and a cap that +// is less than 2*n. If clear is true, the data slice visible +// through the Matrix interface is zeroed. +func getWorkspaceTri(n int, kind TriKind, clear bool) *TriDense { l := uint64(n) l *= l t := poolTri[bits(l)].Get().(*TriDense) @@ -137,37 +157,31 @@ func getWorkspaceTri(n int, kind matrix.TriKind, clear bool) *TriDense { } t.mat.N = n t.mat.Stride = n - if kind == matrix.Upper { + if kind == Upper { t.mat.Uplo = blas.Upper - } else if kind == matrix.Lower { + } else if kind == Lower { t.mat.Uplo = blas.Lower } else { - panic(matrix.ErrTriangle) + panic(ErrTriangle) } t.mat.Diag = blas.NonUnit t.cap = n return t } -// putWorkspaceSym replaces a used *SymDense into the appropriate size -// workspace pool. putWorkspaceSym must not be called with a matrix -// where references to the underlying data slice has been kept. -func putWorkspaceSym(s *SymDense) { - poolSym[bits(uint64(cap(s.mat.Data)))].Put(s) -} - // putWorkspaceTri replaces a used *TriDense into the appropriate size // workspace pool. putWorkspaceTri must not be called with a matrix -// where references to the underlying data slice has been kept. +// where references to the underlying data slice have been kept. func putWorkspaceTri(t *TriDense) { poolTri[bits(uint64(cap(t.mat.Data)))].Put(t) } -// getWorkspaceVec returns a *Vector of length n and a cap that is less than 2*n. If clear is true, the -// data slice visible through the Matrix interface is zeroed. -func getWorkspaceVec(n int, clear bool) *Vector { +// getWorkspaceVec returns a *VecDense of length n and a cap that +// is less than 2*n. If clear is true, the data slice visible +// through the Matrix interface is zeroed. +func getWorkspaceVec(n int, clear bool) *VecDense { l := uint64(n) - v := poolVec[bits(l)].Get().(*Vector) + v := poolVec[bits(l)].Get().(*VecDense) v.mat.Data = v.mat.Data[:l] if clear { zero(v.mat.Data) @@ -176,9 +190,47 @@ func getWorkspaceVec(n int, clear bool) *Vector { return v } -// putWorkspaceVec replaces a used *Vector into the appropriate size +// putWorkspaceVec replaces a used *VecDense into the appropriate size // workspace pool. putWorkspaceVec must not be called with a matrix -// where references to the underlying data slice has been kept. -func putWorkspaceVec(v *Vector) { +// where references to the underlying data slice have been kept. +func putWorkspaceVec(v *VecDense) { poolVec[bits(uint64(cap(v.mat.Data)))].Put(v) } + +// getFloats returns a []float64 of length l and a cap that is +// less than 2*l. If clear is true, the slice visible is zeroed. +func getFloats(l int, clear bool) []float64 { + w := poolFloats[bits(uint64(l))].Get().([]float64) + w = w[:l] + if clear { + zero(w) + } + return w +} + +// putFloats replaces a used []float64 into the appropriate size +// workspace pool. putFloats must not be called with a slice +// where references to the underlying data have been kept. +func putFloats(w []float64) { + poolFloats[bits(uint64(cap(w)))].Put(w) +} + +// getInts returns a []ints of length l and a cap that is +// less than 2*l. If clear is true, the slice visible is zeroed. +func getInts(l int, clear bool) []int { + w := poolInts[bits(uint64(l))].Get().([]int) + w = w[:l] + if clear { + for i := range w { + w[i] = 0 + } + } + return w +} + +// putInts replaces a used []int into the appropriate size +// workspace pool. putInts must not be called with a slice +// where references to the underlying data have been kept. +func putInts(w []int) { + poolInts[bits(uint64(cap(w)))].Put(w) +} diff --git a/vendor/github.com/gonum/matrix/mat64/product.go b/vendor/gonum.org/v1/gonum/mat/product.go similarity index 94% rename from vendor/github.com/gonum/matrix/mat64/product.go rename to vendor/gonum.org/v1/gonum/mat/product.go index c3b57c71..08424ab3 100644 --- a/vendor/github.com/gonum/matrix/mat64/product.go +++ b/vendor/gonum.org/v1/gonum/mat/product.go @@ -1,14 +1,10 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat -import ( - "fmt" - - "github.com/gonum/matrix" -) +import "fmt" // Product calculates the product of the given factors and places the result in // the receiver. The order of multiplication operations is optimized to minimize @@ -31,7 +27,7 @@ func (m *Dense) Product(factors ...Matrix) { switch len(factors) { case 0: if r != 0 || c != 0 { - panic(matrix.ErrShape) + panic(ErrShape) } return case 1: @@ -75,12 +71,12 @@ func newMultiplier(m *Dense, factors []Matrix) *multiplier { // allocate data for m. r, c := m.Dims() fr, fc := factors[0].Dims() // newMultiplier is only called with len(factors) > 2. - if !m.isZero() { + if !m.IsZero() { if fr != r { - panic(matrix.ErrShape) + panic(ErrShape) } if _, lc := factors[len(factors)-1].Dims(); lc != c { - panic(matrix.ErrShape) + panic(ErrShape) } } @@ -92,7 +88,7 @@ func newMultiplier(m *Dense, factors []Matrix) *multiplier { cr, cc := f.Dims() dims[i+1] = cr if pc != cr { - panic(matrix.ErrShape) + panic(ErrShape) } pc = cc } @@ -150,7 +146,7 @@ func (p *multiplier) multiplySubchain(i, j int) (m Matrix, intermediate bool) { if ac != br { // Panic with a string since this // is not a user-facing panic. - panic(matrix.ErrShape.Error()) + panic(ErrShape.Error()) } if debugProductWalk { diff --git a/vendor/gonum.org/v1/gonum/mat/qr.go b/vendor/gonum.org/v1/gonum/mat/qr.go new file mode 100644 index 00000000..c93da63d --- /dev/null +++ b/vendor/gonum.org/v1/gonum/mat/qr.go @@ -0,0 +1,233 @@ +// Copyright ©2013 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mat + +import ( + "math" + + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" + "gonum.org/v1/gonum/lapack/lapack64" +) + +// QR is a type for creating and using the QR factorization of a matrix. +type QR struct { + qr *Dense + tau []float64 + cond float64 +} + +func (qr *QR) updateCond(norm lapack.MatrixNorm) { + // Since A = Q*R, and Q is orthogonal, we get for the condition number κ + // κ(A) := |A| |A^-1| = |Q*R| |(Q*R)^-1| = |R| |R^-1 * Q^T| + // = |R| |R^-1| = κ(R), + // where we used that fact that Q^-1 = Q^T. However, this assumes that + // the matrix norm is invariant under orthogonal transformations which + // is not the case for CondNorm. Hopefully the error is negligible: κ + // is only a qualitative measure anyway. + n := qr.qr.mat.Cols + work := getFloats(3*n, false) + iwork := getInts(n, false) + r := qr.qr.asTriDense(n, blas.NonUnit, blas.Upper) + v := lapack64.Trcon(norm, r.mat, work, iwork) + putFloats(work) + putInts(iwork) + qr.cond = 1 / v +} + +// Factorize computes the QR factorization of an m×n matrix a where m >= n. The QR +// factorization always exists even if A is singular. +// +// The QR decomposition is a factorization of the matrix A such that A = Q * R. +// The matrix Q is an orthonormal m×m matrix, and R is an m×n upper triangular matrix. +// Q and R can be extracted using the QTo and RTo methods. +func (qr *QR) Factorize(a Matrix) { + qr.factorize(a, CondNorm) +} + +func (qr *QR) factorize(a Matrix, norm lapack.MatrixNorm) { + m, n := a.Dims() + if m < n { + panic(ErrShape) + } + k := min(m, n) + if qr.qr == nil { + qr.qr = &Dense{} + } + qr.qr.Clone(a) + work := []float64{0} + qr.tau = make([]float64, k) + lapack64.Geqrf(qr.qr.mat, qr.tau, work, -1) + + work = getFloats(int(work[0]), false) + lapack64.Geqrf(qr.qr.mat, qr.tau, work, len(work)) + putFloats(work) + qr.updateCond(norm) +} + +// Cond returns the condition number for the factorized matrix. +// Cond will panic if the receiver does not contain a successful factorization. +func (qr *QR) Cond() float64 { + if qr.qr == nil || qr.qr.IsZero() { + panic("qr: no decomposition computed") + } + return qr.cond +} + +// TODO(btracey): Add in the "Reduced" forms for extracting the n×n orthogonal +// and upper triangular matrices. + +// RTo extracts the m×n upper trapezoidal matrix from a QR decomposition. +// If dst is nil, a new matrix is allocated. The resulting dst matrix is returned. +func (qr *QR) RTo(dst *Dense) *Dense { + r, c := qr.qr.Dims() + if dst == nil { + dst = NewDense(r, c, nil) + } else { + dst.reuseAs(r, c) + } + + // Disguise the QR as an upper triangular + t := &TriDense{ + mat: blas64.Triangular{ + N: c, + Stride: qr.qr.mat.Stride, + Data: qr.qr.mat.Data, + Uplo: blas.Upper, + Diag: blas.NonUnit, + }, + cap: qr.qr.capCols, + } + dst.Copy(t) + + // Zero below the triangular. + for i := r; i < c; i++ { + zero(dst.mat.Data[i*dst.mat.Stride : i*dst.mat.Stride+c]) + } + + return dst +} + +// QTo extracts the m×m orthonormal matrix Q from a QR decomposition. +// If dst is nil, a new matrix is allocated. The resulting Q matrix is returned. +func (qr *QR) QTo(dst *Dense) *Dense { + r, _ := qr.qr.Dims() + if dst == nil { + dst = NewDense(r, r, nil) + } else { + dst.reuseAsZeroed(r, r) + } + + // Set Q = I. + for i := 0; i < r*r; i += r + 1 { + dst.mat.Data[i] = 1 + } + + // Construct Q from the elementary reflectors. + work := []float64{0} + lapack64.Ormqr(blas.Left, blas.NoTrans, qr.qr.mat, qr.tau, dst.mat, work, -1) + work = getFloats(int(work[0]), false) + lapack64.Ormqr(blas.Left, blas.NoTrans, qr.qr.mat, qr.tau, dst.mat, work, len(work)) + putFloats(work) + + return dst +} + +// Solve finds a minimum-norm solution to a system of linear equations defined +// by the matrices A and b, where A is an m×n matrix represented in its QR factorized +// form. If A is singular or near-singular a Condition error is returned. +// See the documentation for Condition for more information. +// +// The minimization problem solved depends on the input parameters. +// If trans == false, find X such that ||A*X - b||_2 is minimized. +// If trans == true, find the minimum norm solution of A^T * X = b. +// The solution matrix, X, is stored in place into m. +func (qr *QR) Solve(m *Dense, trans bool, b Matrix) error { + r, c := qr.qr.Dims() + br, bc := b.Dims() + + // The QR solve algorithm stores the result in-place into the right hand side. + // The storage for the answer must be large enough to hold both b and x. + // However, this method's receiver must be the size of x. Copy b, and then + // copy the result into m at the end. + if trans { + if c != br { + panic(ErrShape) + } + m.reuseAs(r, bc) + } else { + if r != br { + panic(ErrShape) + } + m.reuseAs(c, bc) + } + // Do not need to worry about overlap between m and b because x has its own + // independent storage. + x := getWorkspace(max(r, c), bc, false) + x.Copy(b) + t := qr.qr.asTriDense(qr.qr.mat.Cols, blas.NonUnit, blas.Upper).mat + if trans { + ok := lapack64.Trtrs(blas.Trans, t, x.mat) + if !ok { + return Condition(math.Inf(1)) + } + for i := c; i < r; i++ { + zero(x.mat.Data[i*x.mat.Stride : i*x.mat.Stride+bc]) + } + work := []float64{0} + lapack64.Ormqr(blas.Left, blas.NoTrans, qr.qr.mat, qr.tau, x.mat, work, -1) + work = getFloats(int(work[0]), false) + lapack64.Ormqr(blas.Left, blas.NoTrans, qr.qr.mat, qr.tau, x.mat, work, len(work)) + putFloats(work) + } else { + work := []float64{0} + lapack64.Ormqr(blas.Left, blas.Trans, qr.qr.mat, qr.tau, x.mat, work, -1) + work = getFloats(int(work[0]), false) + lapack64.Ormqr(blas.Left, blas.Trans, qr.qr.mat, qr.tau, x.mat, work, len(work)) + putFloats(work) + + ok := lapack64.Trtrs(blas.NoTrans, t, x.mat) + if !ok { + return Condition(math.Inf(1)) + } + } + // M was set above to be the correct size for the result. + m.Copy(x) + putWorkspace(x) + if qr.cond > ConditionTolerance { + return Condition(qr.cond) + } + return nil +} + +// SolveVec finds a minimum-norm solution to a system of linear equations, +// Ax = b. +// See QR.Solve for the full documentation. +func (qr *QR) SolveVec(v *VecDense, trans bool, b Vector) error { + r, c := qr.qr.Dims() + if _, bc := b.Dims(); bc != 1 { + panic(ErrShape) + } + + // The Solve implementation is non-trivial, so rather than duplicate the code, + // instead recast the VecDenses as Dense and call the matrix code. + bm := Matrix(b) + if rv, ok := b.(RawVectorer); ok { + bmat := rv.RawVector() + if v != b { + v.checkOverlap(bmat) + } + b := VecDense{mat: bmat, n: b.Len()} + bm = b.asDense() + } + if trans { + v.reuseAs(r) + } else { + v.reuseAs(c) + } + return qr.Solve(v.asDense(), trans, bm) + +} diff --git a/vendor/gonum.org/v1/gonum/mat/shadow.go b/vendor/gonum.org/v1/gonum/mat/shadow.go new file mode 100644 index 00000000..bcc55d6a --- /dev/null +++ b/vendor/gonum.org/v1/gonum/mat/shadow.go @@ -0,0 +1,172 @@ +// Copyright ©2015 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mat + +import ( + "gonum.org/v1/gonum/blas/blas64" +) + +const ( + // regionOverlap is the panic string used for the general case + // of a matrix region overlap between a source and destination. + regionOverlap = "mat: bad region: overlap" + + // regionIdentity is the panic string used for the specific + // case of complete agreement between a source and a destination. + regionIdentity = "mat: bad region: identical" + + // mismatchedStrides is the panic string used for overlapping + // data slices with differing strides. + mismatchedStrides = "mat: bad region: different strides" +) + +// checkOverlap returns false if the receiver does not overlap data elements +// referenced by the parameter and panics otherwise. +// +// checkOverlap methods return a boolean to allow the check call to be added to a +// boolean expression, making use of short-circuit operators. +func checkOverlap(a, b blas64.General) bool { + if cap(a.Data) == 0 || cap(b.Data) == 0 { + return false + } + + off := offset(a.Data[:1], b.Data[:1]) + + if off == 0 { + // At least one element overlaps. + if a.Cols == b.Cols && a.Rows == b.Rows && a.Stride == b.Stride { + panic(regionIdentity) + } + panic(regionOverlap) + } + + if off > 0 && len(a.Data) <= off { + // We know a is completely before b. + return false + } + if off < 0 && len(b.Data) <= -off { + // We know a is completely after b. + return false + } + + if a.Stride != b.Stride { + // Too hard, so assume the worst. + panic(mismatchedStrides) + } + + if off < 0 { + off = -off + a.Cols, b.Cols = b.Cols, a.Cols + } + if rectanglesOverlap(off, a.Cols, b.Cols, a.Stride) { + panic(regionOverlap) + } + return false +} + +func (m *Dense) checkOverlap(a blas64.General) bool { + return checkOverlap(m.RawMatrix(), a) +} + +func (s *SymDense) checkOverlap(a blas64.General) bool { + return checkOverlap(generalFromSymmetric(s.RawSymmetric()), a) +} + +// generalFromSymmetric returns a blas64.General with the backing +// data and dimensions of a. +func generalFromSymmetric(a blas64.Symmetric) blas64.General { + return blas64.General{ + Rows: a.N, + Cols: a.N, + Stride: a.Stride, + Data: a.Data, + } +} + +func (t *TriDense) checkOverlap(a blas64.General) bool { + return checkOverlap(generalFromTriangular(t.RawTriangular()), a) +} + +// generalFromTriangular returns a blas64.General with the backing +// data and dimensions of a. +func generalFromTriangular(a blas64.Triangular) blas64.General { + return blas64.General{ + Rows: a.N, + Cols: a.N, + Stride: a.Stride, + Data: a.Data, + } +} + +func (v *VecDense) checkOverlap(a blas64.Vector) bool { + mat := v.mat + if cap(mat.Data) == 0 || cap(a.Data) == 0 { + return false + } + + off := offset(mat.Data[:1], a.Data[:1]) + + if off == 0 { + // At least one element overlaps. + if mat.Inc == a.Inc && len(mat.Data) == len(a.Data) { + panic(regionIdentity) + } + panic(regionOverlap) + } + + if off > 0 && len(mat.Data) <= off { + // We know v is completely before a. + return false + } + if off < 0 && len(a.Data) <= -off { + // We know v is completely after a. + return false + } + + if mat.Inc != a.Inc { + // Too hard, so assume the worst. + panic(mismatchedStrides) + } + + if mat.Inc == 1 || off&mat.Inc == 0 { + panic(regionOverlap) + } + return false +} + +// rectanglesOverlap returns whether the strided rectangles a and b overlap +// when b is offset by off elements after a but has at least one element before +// the end of a. off must be positive. a and b have aCols and bCols respectively. +// +// rectanglesOverlap works by shifting both matrices left such that the left +// column of a is at 0. The column indexes are flattened by obtaining the shifted +// relative left and right column positions modulo the common stride. This allows +// direct comparison of the column offsets when the matrix backing data slices +// are known to overlap. +func rectanglesOverlap(off, aCols, bCols, stride int) bool { + if stride == 1 { + // Unit stride means overlapping data + // slices must overlap as matrices. + return true + } + + // Flatten the shifted matrix column positions + // so a starts at 0, modulo the common stride. + aTo := aCols + // The mod stride operations here make the from + // and to indexes comparable between a and b when + // the data slices of a and b overlap. + bFrom := off % stride + bTo := (bFrom + bCols) % stride + + if bTo == 0 || bFrom < bTo { + // b matrix is not wrapped: compare for + // simple overlap. + return bFrom < aTo + } + + // b strictly wraps and so must overlap with a. + return true +} diff --git a/vendor/github.com/gonum/matrix/mat64/solve.go b/vendor/gonum.org/v1/gonum/mat/solve.go similarity index 60% rename from vendor/github.com/gonum/matrix/mat64/solve.go rename to vendor/gonum.org/v1/gonum/mat/solve.go index 9a54cb98..c6cfe8f3 100644 --- a/vendor/github.com/gonum/matrix/mat64/solve.go +++ b/vendor/gonum.org/v1/gonum/mat/solve.go @@ -1,19 +1,18 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack/lapack64" ) // Solve finds a minimum-norm solution to a system of linear equations defined // by the matrices a and b. If A is singular or near-singular, a Condition error -// is returned. Please see the documentation for Condition for more information. +// is returned. See the documentation for Condition for more information. // // The minimization problem solved depends on the input parameters: // - if m >= n, find X such that ||A*X - B||_2 is minimized, @@ -23,7 +22,7 @@ func (m *Dense) Solve(a, b Matrix) error { ar, ac := a.Dims() br, bc := b.Dims() if ar != br { - panic(matrix.ErrShape) + panic(ErrShape) } m.reuseAs(ac, bc) @@ -64,11 +63,13 @@ func (m *Dense) Solve(a, b Matrix) error { rm := rma.RawTriangular() blas64.Trsm(side, tA, 1, rm, m.mat) - work := make([]float64, 3*rm.N) - iwork := make([]int, rm.N) - cond := lapack64.Trcon(matrix.CondNorm, rm, work, iwork) - if cond > matrix.ConditionTolerance { - return matrix.Condition(cond) + work := getFloats(3*rm.N, false) + iwork := getInts(rm.N, false) + cond := lapack64.Trcon(CondNorm, rm, work, iwork) + putFloats(work) + putInts(iwork) + if cond > ConditionTolerance { + return Condition(cond) } return nil } @@ -90,37 +91,50 @@ func (m *Dense) Solve(a, b Matrix) error { } var lu LU lu.Factorize(a) - return m.SolveLU(&lu, false, b) + return lu.Solve(m, false, b) case ar > ac: var qr QR qr.Factorize(a) - return m.SolveQR(&qr, false, b) + return qr.Solve(m, false, b) default: var lq LQ lq.Factorize(a) - return m.SolveLQ(&lq, false, b) + return lq.Solve(m, false, b) } } // SolveVec finds a minimum-norm solution to a system of linear equations defined -// by the matrix a and the right-hand side vector b. If A is singular or -// near-singular, a Condition error is returned. Please see the documentation for +// by the matrix a and the right-hand side column vector b. If A is singular or +// near-singular, a Condition error is returned. See the documentation for // Dense.Solve for more information. -func (v *Vector) SolveVec(a Matrix, b *Vector) error { - if v != b { - v.checkOverlap(b.mat) +func (v *VecDense) SolveVec(a Matrix, b Vector) error { + if _, bc := b.Dims(); bc != 1 { + panic(ErrShape) } _, c := a.Dims() + // The Solve implementation is non-trivial, so rather than duplicate the code, - // instead recast the Vectors as Dense and call the matrix code. + // instead recast the VecDenses as Dense and call the matrix code. + + if rv, ok := b.(RawVectorer); ok { + bmat := rv.RawVector() + if v != b { + v.checkOverlap(bmat) + } + v.reuseAs(c) + m := v.asDense() + // We conditionally create bm as m when b and v are identical + // to prevent the overlap detection code from identifying m + // and bm as overlapping but not identical. + bm := m + if v != b { + b := VecDense{mat: bmat, n: b.Len()} + bm = b.asDense() + } + return m.Solve(a, bm) + } + v.reuseAs(c) m := v.asDense() - // We conditionally create bm as m when b and v are identical - // to prevent the overlap detection code from identifying m - // and bm as overlapping but not identical. - bm := m - if v != b { - bm = b.asDense() - } - return m.Solve(a, bm) + return m.Solve(a, b) } diff --git a/vendor/github.com/gonum/matrix/mat64/svd.go b/vendor/gonum.org/v1/gonum/mat/svd.go similarity index 75% rename from vendor/github.com/gonum/matrix/mat64/svd.go rename to vendor/gonum.org/v1/gonum/mat/svd.go index 31c4ee75..ef1f21cf 100644 --- a/vendor/github.com/gonum/matrix/mat64/svd.go +++ b/vendor/gonum.org/v1/gonum/mat/svd.go @@ -1,20 +1,19 @@ -// Copyright ©2013 The gonum Authors. All rights reserved. +// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack" + "gonum.org/v1/gonum/lapack/lapack64" ) // SVD is a type for creating and using the Singular Value Decomposition (SVD) // of a matrix. type SVD struct { - kind matrix.SVDKind + kind SVDKind s []float64 u blas64.General @@ -39,16 +38,16 @@ type SVD struct { // // Factorize returns whether the decomposition succeeded. If the decomposition // failed, routines that require a successful factorization will panic. -func (svd *SVD) Factorize(a Matrix, kind matrix.SVDKind) (ok bool) { +func (svd *SVD) Factorize(a Matrix, kind SVDKind) (ok bool) { m, n := a.Dims() var jobU, jobVT lapack.SVDJob switch kind { default: panic("svd: bad input kind") - case matrix.SVDNone: + case SVDNone: jobU = lapack.SVDNone jobVT = lapack.SVDNone - case matrix.SVDFull: + case SVDFull: // TODO(btracey): This code should be modified to have the smaller // matrix written in-place into aCopy when the lapack/native/dgesvd // implementation is complete. @@ -66,7 +65,7 @@ func (svd *SVD) Factorize(a Matrix, kind matrix.SVDKind) (ok bool) { } jobU = lapack.SVDAll jobVT = lapack.SVDAll - case matrix.SVDThin: + case SVDThin: // TODO(btracey): This code should be modified to have the larger // matrix written in-place into aCopy when the lapack/native/dgesvd // implementation is complete. @@ -91,10 +90,11 @@ func (svd *SVD) Factorize(a Matrix, kind matrix.SVDKind) (ok bool) { svd.kind = kind svd.s = use(svd.s, min(m, n)) - work := make([]float64, 1) + work := []float64{0} lapack64.Gesvd(jobU, jobVT, aCopy.mat, svd.u, svd.vt, svd.s, work, -1) - work = make([]float64, int(work[0])) + work = getFloats(int(work[0]), false) ok = lapack64.Gesvd(jobU, jobVT, aCopy.mat, svd.u, svd.vt, svd.s, work, len(work)) + putFloats(work) if !ok { svd.kind = 0 } @@ -103,7 +103,7 @@ func (svd *SVD) Factorize(a Matrix, kind matrix.SVDKind) (ok bool) { // Kind returns the matrix.SVDKind of the decomposition. If no decomposition has been // computed, Kind returns 0. -func (svd *SVD) Kind() matrix.SVDKind { +func (svd *SVD) Kind() SVDKind { return svd.kind } @@ -131,48 +131,60 @@ func (svd *SVD) Values(s []float64) []float64 { s = make([]float64, len(svd.s)) } if len(s) != len(svd.s) { - panic(matrix.ErrSliceLengthMismatch) + panic(ErrSliceLengthMismatch) } copy(s, svd.s) return s } -// UFromSVD extracts the matrix U from the singular value decomposition, storing -// the result in-place into the receiver. U is size m×m if svd.Kind() == SVDFull, -// of size m×min(m,n) if svd.Kind() == SVDThin, and UFromSVD panics otherwise. -func (m *Dense) UFromSVD(svd *SVD) { +// UTo extracts the matrix U from the singular value decomposition, storing +// the result in-place into dst. U is size m×m if svd.Kind() == SVDFull, +// of size m×min(m,n) if svd.Kind() == SVDThin, and UTo panics otherwise. +func (svd *SVD) UTo(dst *Dense) *Dense { kind := svd.kind - if kind != matrix.SVDFull && kind != matrix.SVDThin { - panic("mat64: improper SVD kind") + if kind != SVDFull && kind != SVDThin { + panic("mat: improper SVD kind") } r := svd.u.Rows c := svd.u.Cols - m.reuseAs(r, c) + if dst == nil { + dst = NewDense(r, c, nil) + } else { + dst.reuseAs(r, c) + } tmp := &Dense{ mat: svd.u, capRows: r, capCols: c, } - m.Copy(tmp) + dst.Copy(tmp) + + return dst } -// VFromSVD extracts the matrix V from the singular value decomposition, storing -// the result in-place into the receiver. V is size n×n if svd.Kind() == SVDFull, -// of size n×min(m,n) if svd.Kind() == SVDThin, and VFromSVD panics otherwise. -func (m *Dense) VFromSVD(svd *SVD) { +// VTo extracts the matrix V from the singular value decomposition, storing +// the result in-place into dst. V is size n×n if svd.Kind() == SVDFull, +// of size n×min(m,n) if svd.Kind() == SVDThin, and VTo panics otherwise. +func (svd *SVD) VTo(dst *Dense) *Dense { kind := svd.kind - if kind != matrix.SVDFull && kind != matrix.SVDThin { - panic("mat64: improper SVD kind") + if kind != SVDFull && kind != SVDThin { + panic("mat: improper SVD kind") } r := svd.vt.Rows c := svd.vt.Cols - m.reuseAs(c, r) + if dst == nil { + dst = NewDense(c, r, nil) + } else { + dst.reuseAs(c, r) + } tmp := &Dense{ mat: svd.vt, capRows: r, capCols: c, } - m.Copy(tmp.T()) + dst.Copy(tmp.T()) + + return dst } diff --git a/vendor/gonum.org/v1/gonum/mat/symband.go b/vendor/gonum.org/v1/gonum/mat/symband.go new file mode 100644 index 00000000..967c5ff3 --- /dev/null +++ b/vendor/gonum.org/v1/gonum/mat/symband.go @@ -0,0 +1,175 @@ +// Copyright ©2017 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mat + +import ( + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" +) + +var ( + symBandDense *SymBandDense + _ Matrix = symBandDense + _ Symmetric = symBandDense + _ Banded = symBandDense + _ RawSymBander = symBandDense + _ MutableSymBanded = symBandDense + + _ NonZeroDoer = symBandDense + _ RowNonZeroDoer = symBandDense + _ ColNonZeroDoer = symBandDense +) + +// SymBandDense represents a symmetric band matrix in dense storage format. +type SymBandDense struct { + mat blas64.SymmetricBand +} + +// MutableSymBanded is a symmetric band matrix interface type that allows elements +// to be altered. +type MutableSymBanded interface { + Symmetric + Bandwidth() (kl, ku int) + SetSymBand(i, j int, v float64) +} + +// A RawSymBander can return a blas64.SymmetricBand representation of the receiver. +// Changes to the blas64.SymmetricBand.Data slice will be reflected in the original +// matrix, changes to the N, K, Stride and Uplo fields will not. +type RawSymBander interface { + RawSymBand() blas64.SymmetricBand +} + +// NewSymBandDense creates a new SymBand matrix with n rows and columns. If data == nil, +// a new slice is allocated for the backing slice. If len(data) == n*(k+1), +// data is used as the backing slice, and changes to the elements of the returned +// SymBandDense will be reflected in data. If neither of these is true, NewSymBandDense +// will panic. k must be at least zero and less than n, otherwise NewBandDense will panic. +// +// The data must be arranged in row-major order constructed by removing the zeros +// from the rows outside the band and aligning the diagonals. SymBandDense matrices +// are stored in the upper triangle. For example, the matrix +// 1 2 3 0 0 0 +// 2 4 5 6 0 0 +// 3 5 7 8 9 0 +// 0 6 8 10 11 12 +// 0 0 9 11 13 14 +// 0 0 0 12 14 15 +// becomes (* entries are never accessed) +// 1 2 3 +// 4 5 6 +// 7 8 9 +// 10 11 12 +// 13 14 * +// 15 * * +// which is passed to NewBandDense as []float64{1, 2, 3, 4, ...} with k=2. +// Only the values in the band portion of the matrix are used. +func NewSymBandDense(n, k int, data []float64) *SymBandDense { + if n < 0 || k < 0 { + panic("mat: negative dimension") + } + if k+1 > n { + panic("mat: band out of range") + } + bc := k + 1 + if data != nil && len(data) != n*bc { + panic(ErrShape) + } + if data == nil { + data = make([]float64, n*bc) + } + return &SymBandDense{ + mat: blas64.SymmetricBand{ + N: n, + K: k, + Stride: bc, + Uplo: blas.Upper, + Data: data, + }, + } +} + +// NewDiagonal is a convenience function that returns a diagonal matrix represented by a +// SymBandDense. The length of data must be n or data must be nil, otherwise NewDiagonal +// will panic. +func NewDiagonal(n int, data []float64) *SymBandDense { + return NewSymBandDense(n, 0, data) +} + +// Dims returns the number of rows and columns in the matrix. +func (s *SymBandDense) Dims() (r, c int) { + return s.mat.N, s.mat.N +} + +// Symmetric returns the size of the receiver. +func (s *SymBandDense) Symmetric() int { + return s.mat.N +} + +// Bandwidth returns the bandwidths of the matrix. +func (s *SymBandDense) Bandwidth() (kl, ku int) { + return s.mat.K, s.mat.K +} + +// T implements the Matrix interface. Symmetric matrices, by definition, are +// equal to their transpose, and this is a no-op. +func (s *SymBandDense) T() Matrix { + return s +} + +// TBand implements the Banded interface. +func (s *SymBandDense) TBand() Banded { + return s +} + +// RawSymBand returns the underlying blas64.SymBand used by the receiver. +// Changes to elements in the receiver following the call will be reflected +// in returned blas64.SymBand. +func (s *SymBandDense) RawSymBand() blas64.SymmetricBand { + return s.mat +} + +// DoNonZero calls the function fn for each of the non-zero elements of s. The function fn +// takes a row/column index and the element value of s at (i, j). +func (s *SymBandDense) DoNonZero(fn func(i, j int, v float64)) { + for i := 0; i < s.mat.N; i++ { + for j := max(0, i-s.mat.K); j < min(s.mat.N, i+s.mat.K+1); j++ { + v := s.at(i, j) + if v != 0 { + fn(i, j, v) + } + } + } +} + +// DoRowNonZero calls the function fn for each of the non-zero elements of row i of s. The function fn +// takes a row/column index and the element value of s at (i, j). +func (s *SymBandDense) DoRowNonZero(i int, fn func(i, j int, v float64)) { + if i < 0 || s.mat.N <= i { + panic(ErrRowAccess) + } + for j := max(0, i-s.mat.K); j < min(s.mat.N, i+s.mat.K+1); j++ { + v := s.at(i, j) + if v != 0 { + fn(i, j, v) + } + } +} + +// DoColNonZero calls the function fn for each of the non-zero elements of column j of s. The function fn +// takes a row/column index and the element value of s at (i, j). +func (s *SymBandDense) DoColNonZero(j int, fn func(i, j int, v float64)) { + if j < 0 || s.mat.N <= j { + panic(ErrColAccess) + } + for i := 0; i < s.mat.N; i++ { + if i-s.mat.K <= j && j < i+s.mat.K+1 { + v := s.at(i, j) + if v != 0 { + fn(i, j, v) + } + } + } +} diff --git a/vendor/github.com/gonum/matrix/mat64/symmetric.go b/vendor/gonum.org/v1/gonum/mat/symmetric.go similarity index 85% rename from vendor/github.com/gonum/matrix/mat64/symmetric.go rename to vendor/gonum.org/v1/gonum/mat/symmetric.go index 21a1b3ff..9ef2b3ed 100644 --- a/vendor/github.com/gonum/matrix/mat64/symmetric.go +++ b/vendor/gonum.org/v1/gonum/mat/symmetric.go @@ -1,15 +1,14 @@ -// Copyright ©2015 The gonum Authors. All rights reserved. +// Copyright ©2015 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package mat64 +package mat import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" ) var ( @@ -22,8 +21,8 @@ var ( ) const ( - badSymTriangle = "mat64: blas64.Symmetric not upper" - badSymCap = "mat64: bad capacity for SymDense" + badSymTriangle = "mat: blas64.Symmetric not upper" + badSymCap = "mat: bad capacity for SymDense" ) // SymDense is a symmetric matrix that uses dense storage. SymDense @@ -46,6 +45,7 @@ type RawSymmetricer interface { RawSymmetric() blas64.Symmetric } +// A MutableSymmetric can set elements of a symmetric matrix. type MutableSymmetric interface { Symmetric SetSym(i, j int, v float64) @@ -61,10 +61,10 @@ type MutableSymmetric interface { // Only the values in the upper triangular portion of the matrix are used. func NewSymDense(n int, data []float64) *SymDense { if n < 0 { - panic("mat64: negative dimension") + panic("mat: negative dimension") } if data != nil && n*n != len(data) { - panic(matrix.ErrShape) + panic(ErrShape) } if data == nil { data = make([]float64, n*n) @@ -80,10 +80,16 @@ func NewSymDense(n int, data []float64) *SymDense { } } +// Dims returns the number of rows and columns in the matrix. func (s *SymDense) Dims() (r, c int) { return s.mat.N, s.mat.N } +// Caps returns the number of rows and columns in the backing matrix. +func (s *SymDense) Caps() (r, c int) { + return s.cap, s.cap +} + // T implements the Matrix interface. Symmetric matrices, by definition, are // equal to their transpose, and this is a no-op. func (s *SymDense) T() Matrix { @@ -121,7 +127,9 @@ func (s *SymDense) Reset() { s.mat.Data = s.mat.Data[:0] } -func (s *SymDense) isZero() bool { +// IsZero returns whether the receiver is zero-sized. Zero-sized matrices can be the +// receiver for size-restricted operations. SymDense matrices can be zeroed using Reset. +func (s *SymDense) IsZero() bool { // It must be the case that m.Dims() returns // zeros in this case. See comment in Reset(). return s.mat.N == 0 @@ -133,7 +141,7 @@ func (s *SymDense) reuseAs(n int) { if s.mat.N > s.cap { panic(badSymCap) } - if s.isZero() { + if s.IsZero() { s.mat = blas64.Symmetric{ N: n, Stride: n, @@ -147,7 +155,7 @@ func (s *SymDense) reuseAs(n int) { panic(badSymTriangle) } if s.mat.N != n { - panic(matrix.ErrShape) + panic(ErrShape) } } @@ -163,7 +171,7 @@ func (s *SymDense) isolatedWorkspace(a Symmetric) (w *SymDense, restore func()) func (s *SymDense) AddSym(a, b Symmetric) { n := a.Symmetric() if n != b.Symmetric() { - panic(matrix.ErrShape) + panic(ErrShape) } s.reuseAs(n) @@ -171,10 +179,10 @@ func (s *SymDense) AddSym(a, b Symmetric) { if b, ok := b.(RawSymmetricer); ok { amat, bmat := a.RawSymmetric(), b.RawSymmetric() if s != a { - s.checkOverlap(amat) + s.checkOverlap(generalFromSymmetric(amat)) } if s != b { - s.checkOverlap(bmat) + s.checkOverlap(generalFromSymmetric(bmat)) } for i := 0; i < n; i++ { btmp := bmat.Data[i*bmat.Stride+i : i*bmat.Stride+n] @@ -224,15 +232,15 @@ func (s *SymDense) CopySym(a Symmetric) int { // SymRankOne performs a symetric rank-one update to the matrix a and stores // the result in the receiver // s = a + alpha * x * x' -func (s *SymDense) SymRankOne(a Symmetric, alpha float64, x *Vector) { +func (s *SymDense) SymRankOne(a Symmetric, alpha float64, x *VecDense) { n := x.Len() if a.Symmetric() != n { - panic(matrix.ErrShape) + panic(ErrShape) } s.reuseAs(n) if s != a { if rs, ok := a.(RawSymmetricer); ok { - s.checkOverlap(rs.RawSymmetric()) + s.checkOverlap(generalFromSymmetric(rs.RawSymmetric())) } s.CopySym(a) } @@ -246,7 +254,7 @@ func (s *SymDense) SymRankK(a Symmetric, alpha float64, x Matrix) { n := a.Symmetric() r, _ := x.Dims() if r != n { - panic(matrix.ErrShape) + panic(ErrShape) } xMat, aTrans := untranspose(x) var g blas64.General @@ -258,7 +266,7 @@ func (s *SymDense) SymRankK(a Symmetric, alpha float64, x Matrix) { } if a != s { if rs, ok := a.(RawSymmetricer); ok { - s.checkOverlap(rs.RawSymmetric()) + s.checkOverlap(generalFromSymmetric(rs.RawSymmetric())) } s.reuseAs(n) s.CopySym(a) @@ -278,7 +286,7 @@ func (s *SymDense) SymRankK(a Symmetric, alpha float64, x Matrix) { func (s *SymDense) SymOuterK(alpha float64, x Matrix) { n, _ := x.Dims() switch { - case s.isZero(): + case s.IsZero(): s.mat = blas64.Symmetric{ N: n, Stride: n, @@ -296,8 +304,13 @@ func (s *SymDense) SymOuterK(alpha float64, x Matrix) { s.CopySym(w) putWorkspaceSym(w) } else { - if rs, ok := x.(RawSymmetricer); ok { - s.checkOverlap(rs.RawSymmetric()) + switch r := x.(type) { + case RawMatrixer: + s.checkOverlap(r.RawMatrix()) + case RawSymmetricer: + s.checkOverlap(generalFromSymmetric(r.RawSymmetric())) + case RawTriangular: + s.checkOverlap(generalFromTriangular(r.RawTriangular())) } // Only zero the upper triangle. for i := 0; i < n; i++ { @@ -307,20 +320,20 @@ func (s *SymDense) SymOuterK(alpha float64, x Matrix) { s.SymRankK(s, alpha, x) } default: - panic(matrix.ErrShape) + panic(ErrShape) } } // RankTwo performs a symmmetric rank-two update to the matrix a and stores // the result in the receiver // m = a + alpha * (x * y' + y * x') -func (s *SymDense) RankTwo(a Symmetric, alpha float64, x, y *Vector) { +func (s *SymDense) RankTwo(a Symmetric, alpha float64, x, y *VecDense) { n := s.mat.N if x.Len() != n { - panic(matrix.ErrShape) + panic(ErrShape) } if y.Len() != n { - panic(matrix.ErrShape) + panic(ErrShape) } var w SymDense if s == a { @@ -329,13 +342,12 @@ func (s *SymDense) RankTwo(a Symmetric, alpha float64, x, y *Vector) { w.reuseAs(n) if s != a { if rs, ok := a.(RawSymmetricer); ok { - s.checkOverlap(rs.RawSymmetric()) + s.checkOverlap(generalFromSymmetric(rs.RawSymmetric())) } w.CopySym(a) } blas64.Syr2(alpha, x.mat, y.mat, w.mat) *s = w - return } // ScaleSym multiplies the elements of a by f, placing the result in the receiver. @@ -345,7 +357,7 @@ func (s *SymDense) ScaleSym(f float64, a Symmetric) { if a, ok := a.(RawSymmetricer); ok { amat := a.RawSymmetric() if s != a { - s.checkOverlap(amat) + s.checkOverlap(generalFromSymmetric(amat)) } for i := 0; i < n; i++ { for j := i; j < n; j++ { @@ -379,7 +391,7 @@ func (s *SymDense) SubsetSym(a Symmetric, set []int) { if a, ok := a.(RawSymmetricer); ok { raw := a.RawSymmetric() if s != a { - s.checkOverlap(raw) + s.checkOverlap(generalFromSymmetric(raw)) } for i := 0; i < n; i++ { ssub := s.mat.Data[i*s.mat.Stride : i*s.mat.Stride+n] @@ -403,24 +415,15 @@ func (s *SymDense) SubsetSym(a Symmetric, set []int) { } } -// ViewSquare returns a view of the submatrix starting at {i, i} and extending -// for n rows and columns. ViewSquare panics if the view is outside the bounds -// of the receiver. -// -// ViewSquare is deprecated and should not be used. It will be removed at a later date. -func (s *SymDense) ViewSquare(i, n int) Matrix { - return s.SliceSquare(i, i+n) -} - // SliceSquare returns a new Matrix that shares backing data with the receiver. -// The returned matrix starts at {i,i} of the recevier and extends k-i rows +// The returned matrix starts at {i,i} of the receiver and extends k-i rows // and columns. The final row and column in the resulting matrix is k-1. -// SliceSquare panics with ErrIndexOutOfRange if the slice is outside the bounds +// SliceSquare panics with ErrIndexOutOfRange if the slice is outside the capacity // of the receiver. func (s *SymDense) SliceSquare(i, k int) Matrix { - sz := s.Symmetric() + sz := s.cap if i < 0 || sz < i || k < i || sz < k { - panic(matrix.ErrIndexOutOfRange) + panic(ErrIndexOutOfRange) } v := *s v.mat.Data = s.mat.Data[i*s.mat.Stride+i : (k-1)*s.mat.Stride+k] @@ -435,7 +438,7 @@ func (s *SymDense) SliceSquare(i, k int) Matrix { // not modified during the call to GrowSquare. func (s *SymDense) GrowSquare(n int) Matrix { if n < 0 { - panic(matrix.ErrIndexOutOfRange) + panic(ErrIndexOutOfRange) } if n == 0 { return s @@ -484,12 +487,12 @@ func (s *SymDense) PowPSD(a Symmetric, pow float64) error { var eigen EigenSym ok := eigen.Factorize(a, true) if !ok { - return matrix.ErrFailedEigen + return ErrFailedEigen } values := eigen.Values(nil) for i, v := range values { if v <= 0 { - return matrix.ErrNotPSD + return ErrNotPSD } values[i] = math.Pow(v, pow) } @@ -497,8 +500,11 @@ func (s *SymDense) PowPSD(a Symmetric, pow float64) error { u.EigenvectorsSym(&eigen) s.SymOuterK(values[0], u.ColView(0)) + + var v VecDense for i := 1; i < dim; i++ { - s.SymRankOne(s, values[i], u.ColView(i)) + v.ColViewOf(&u, i) + s.SymRankOne(s, values[i], &v) } return nil } diff --git a/vendor/github.com/gonum/matrix/mat64/triangular.go b/vendor/gonum.org/v1/gonum/mat/triangular.go similarity index 68% rename from vendor/github.com/gonum/matrix/mat64/triangular.go rename to vendor/gonum.org/v1/gonum/mat/triangular.go index fb79a375..c49e0078 100644 --- a/vendor/github.com/gonum/matrix/mat64/triangular.go +++ b/vendor/gonum.org/v1/gonum/mat/triangular.go @@ -1,22 +1,30 @@ -package mat64 +// Copyright ©2015 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mat import ( "math" - "github.com/gonum/blas" - "github.com/gonum/blas/blas64" - "github.com/gonum/lapack/lapack64" - "github.com/gonum/matrix" + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/lapack/lapack64" ) var ( triDense *TriDense - _ Matrix = triDense - _ Triangular = triDense - _ RawTriangular = triDense + _ Matrix = triDense + _ Triangular = triDense + _ RawTriangular = triDense + _ MutableTriangular = triDense + + _ NonZeroDoer = triDense + _ RowNonZeroDoer = triDense + _ ColNonZeroDoer = triDense ) -const badTriCap = "mat64: bad capacity for TriDense" +const badTriCap = "mat: bad capacity for TriDense" // TriDense represents an upper or lower triangular matrix in dense storage // format. @@ -25,21 +33,29 @@ type TriDense struct { cap int } +// Triangular represents a triangular matrix. Triangular matrices are always square. type Triangular interface { Matrix // Triangular returns the number of rows/columns in the matrix and its // orientation. - Triangle() (n int, kind matrix.TriKind) + Triangle() (n int, kind TriKind) // TTri is the equivalent of the T() method in the Matrix interface but // guarantees the transpose is of triangular type. TTri() Triangular } +// A RawTriangular can return a view of itself as a BLAS Triangular matrix. type RawTriangular interface { RawTriangular() blas64.Triangular } +// A MutableTriangular can set elements of a triangular matrix. +type MutableTriangular interface { + Triangular + SetTri(i, j int, v float64) +} + var ( _ Matrix = TransposeTri{} _ Triangular = TransposeTri{} @@ -72,7 +88,7 @@ func (t TransposeTri) T() Matrix { } // Triangle returns the number of rows/columns in the matrix and its orientation. -func (t TransposeTri) Triangle() (int, matrix.TriKind) { +func (t TransposeTri) Triangle() (int, TriKind) { n, upper := t.Triangular.Triangle() return n, !upper } @@ -99,18 +115,18 @@ func (t TransposeTri) UntransposeTri() Triangular { // The data must be arranged in row-major order, i.e. the (i*c + j)-th // element in the data slice is the {i, j}-th element in the matrix. // Only the values in the triangular portion corresponding to kind are used. -func NewTriDense(n int, kind matrix.TriKind, data []float64) *TriDense { +func NewTriDense(n int, kind TriKind, data []float64) *TriDense { if n < 0 { - panic("mat64: negative dimension") + panic("mat: negative dimension") } if data != nil && len(data) != n*n { - panic(matrix.ErrShape) + panic(ErrShape) } if data == nil { data = make([]float64, n*n) } uplo := blas.Lower - if kind == matrix.Upper { + if kind == Upper { uplo = blas.Upper } return &TriDense{ @@ -131,16 +147,16 @@ func (t *TriDense) Dims() (r, c int) { // Triangle returns the dimension of t and its orientation. The returned // orientation is only valid when n is not zero. -func (t *TriDense) Triangle() (n int, kind matrix.TriKind) { - return t.mat.N, matrix.TriKind(!t.isZero()) && t.triKind() +func (t *TriDense) Triangle() (n int, kind TriKind) { + return t.mat.N, TriKind(!t.IsZero()) && t.triKind() } func (t *TriDense) isUpper() bool { return isUpperUplo(t.mat.Uplo) } -func (t *TriDense) triKind() matrix.TriKind { - return matrix.TriKind(isUpperUplo(t.mat.Uplo)) +func (t *TriDense) triKind() TriKind { + return TriKind(isUpperUplo(t.mat.Uplo)) } func isUpperUplo(u blas.Uplo) bool { @@ -160,7 +176,7 @@ func isUpperUplo(u blas.Uplo) bool { // be upper triangular. func (t *TriDense) asSymBlas() blas64.Symmetric { if t.mat.Diag == blas.Unit { - panic("mat64: cannot convert unit TriDense into blas64.Symmetric") + panic("mat: cannot convert unit TriDense into blas64.Symmetric") } return blas64.Symmetric{ N: t.mat.N, @@ -197,7 +213,9 @@ func (t *TriDense) Reset() { t.mat.Data = t.mat.Data[:0] } -func (t *TriDense) isZero() bool { +// IsZero returns whether the receiver is zero-sized. Zero-sized matrices can be the +// receiver for size-restricted operations. TriDense matrices can be zeroed using Reset. +func (t *TriDense) IsZero() bool { // It must be the case that t.Dims() returns // zeros in this case. See comment in Reset(). return t.mat.Stride == 0 @@ -216,15 +234,15 @@ func untransposeTri(a Triangular) (Triangular, bool) { // reuseAs resizes a zero receiver to an n×n triangular matrix with the given // orientation. If the receiver is non-zero, reuseAs checks that the receiver // is the correct size and orientation. -func (t *TriDense) reuseAs(n int, kind matrix.TriKind) { +func (t *TriDense) reuseAs(n int, kind TriKind) { ul := blas.Lower - if kind == matrix.Upper { + if kind == Upper { ul = blas.Upper } if t.mat.N > t.cap { panic(badTriCap) } - if t.isZero() { + if t.IsZero() { t.mat = blas64.Triangular{ N: n, Stride: n, @@ -236,10 +254,10 @@ func (t *TriDense) reuseAs(n int, kind matrix.TriKind) { return } if t.mat.N != n { - panic(matrix.ErrShape) + panic(ErrShape) } if t.mat.Uplo != ul { - panic(matrix.ErrTriangle) + panic(ErrTriangle) } } @@ -326,23 +344,25 @@ func (t *TriDense) Copy(a Matrix) (r, c int) { // avoided where possible, for example by using the Solve routines. func (t *TriDense) InverseTri(a Triangular) error { if rt, ok := a.(RawTriangular); ok { - t.checkOverlap(rt.RawTriangular()) + t.checkOverlap(generalFromTriangular(rt.RawTriangular())) } n, _ := a.Triangle() t.reuseAs(a.Triangle()) t.Copy(a) - work := make([]float64, 3*n) - iwork := make([]int, n) - cond := lapack64.Trcon(matrix.CondNorm, t.mat, work, iwork) + work := getFloats(3*n, false) + iwork := getInts(n, false) + cond := lapack64.Trcon(CondNorm, t.mat, work, iwork) + putFloats(work) + putInts(iwork) if math.IsInf(cond, 1) { - return matrix.Condition(cond) + return Condition(cond) } ok := lapack64.Trtri(t.mat) if !ok { - return matrix.Condition(math.Inf(1)) + return Condition(math.Inf(1)) } - if cond > matrix.ConditionTolerance { - return matrix.Condition(cond) + if cond > ConditionTolerance { + return Condition(cond) } return nil } @@ -354,10 +374,10 @@ func (t *TriDense) MulTri(a, b Triangular) { n, kind := a.Triangle() nb, kindb := b.Triangle() if n != nb { - panic(matrix.ErrShape) + panic(ErrShape) } if kind != kindb { - panic(matrix.ErrTriangle) + panic(ErrTriangle) } aU, _ := untransposeTri(a) @@ -373,7 +393,7 @@ func (t *TriDense) MulTri(a, b Triangular) { } // TODO(btracey): Improve the set of fast-paths. - if kind == matrix.Upper { + if kind == Upper { for i := 0; i < n; i++ { for j := i; j < n; j++ { var v float64 @@ -396,12 +416,57 @@ func (t *TriDense) MulTri(a, b Triangular) { } } +// ScaleTri multiplies the elements of a by f, placing the result in the receiver. +// If the receiver is non-zero, the size and kind of the receiver must match +// the input, or ScaleTri will panic. +func (t *TriDense) ScaleTri(f float64, a Triangular) { + n, kind := a.Triangle() + t.reuseAs(n, kind) + + // TODO(btracey): Improve the set of fast-paths. + switch a := a.(type) { + case RawTriangular: + amat := a.RawTriangular() + if kind == Upper { + for i := 0; i < n; i++ { + ts := t.mat.Data[i*t.mat.Stride+i : i*t.mat.Stride+n] + as := amat.Data[i*amat.Stride+i : i*amat.Stride+n] + for i, v := range as { + ts[i] = v * f + } + } + return + } + for i := 0; i < n; i++ { + ts := t.mat.Data[i*t.mat.Stride : i*t.mat.Stride+i+1] + as := amat.Data[i*amat.Stride : i*amat.Stride+i+1] + for i, v := range as { + ts[i] = v * f + } + } + return + default: + isUpper := kind == Upper + for i := 0; i < n; i++ { + if isUpper { + for j := i; j < n; j++ { + t.set(i, j, f*a.At(i, j)) + } + } else { + for j := 0; j <= i; j++ { + t.set(i, j, f*a.At(i, j)) + } + } + } + } +} + // copySymIntoTriangle copies a symmetric matrix into a TriDense func copySymIntoTriangle(t *TriDense, s Symmetric) { n, upper := t.Triangle() ns := s.Symmetric() if n != ns { - panic("mat64: triangle size mismatch") + panic("mat: triangle size mismatch") } ts := t.mat.Stride if rs, ok := s.(RawSymmetricer); ok { @@ -418,8 +483,8 @@ func copySymIntoTriangle(t *TriDense, s Symmetric) { for j := i; j < n; j++ { t.mat.Data[i*ts+j] = sd.Data[j*ss+i] } - return } + return } if sd.Uplo == blas.Upper { for i := 0; i < n; i++ { @@ -448,3 +513,73 @@ func copySymIntoTriangle(t *TriDense, s Symmetric) { } } } + +// DoNonZero calls the function fn for each of the non-zero elements of t. The function fn +// takes a row/column index and the element value of t at (i, j). +func (t *TriDense) DoNonZero(fn func(i, j int, v float64)) { + if t.isUpper() { + for i := 0; i < t.mat.N; i++ { + for j := i; j < t.mat.N; j++ { + v := t.at(i, j) + if v != 0 { + fn(i, j, v) + } + } + } + return + } + for i := 0; i < t.mat.N; i++ { + for j := 0; j <= i; j++ { + v := t.at(i, j) + if v != 0 { + fn(i, j, v) + } + } + } +} + +// DoRowNonZero calls the function fn for each of the non-zero elements of row i of t. The function fn +// takes a row/column index and the element value of t at (i, j). +func (t *TriDense) DoRowNonZero(i int, fn func(i, j int, v float64)) { + if i < 0 || t.mat.N <= i { + panic(ErrRowAccess) + } + if t.isUpper() { + for j := i; j < t.mat.N; j++ { + v := t.at(i, j) + if v != 0 { + fn(i, j, v) + } + } + return + } + for j := 0; j <= i; j++ { + v := t.at(i, j) + if v != 0 { + fn(i, j, v) + } + } +} + +// DoColNonZero calls the function fn for each of the non-zero elements of column j of t. The function fn +// takes a row/column index and the element value of t at (i, j). +func (t *TriDense) DoColNonZero(j int, fn func(i, j int, v float64)) { + if j < 0 || t.mat.N <= j { + panic(ErrColAccess) + } + if t.isUpper() { + for i := 0; i <= j; i++ { + v := t.at(i, j) + if v != 0 { + fn(i, j, v) + } + } + return + } + for i := j; i < t.mat.N; i++ { + v := t.at(i, j) + if v != 0 { + fn(i, j, v) + } + } +} diff --git a/vendor/gonum.org/v1/gonum/mat/vector.go b/vendor/gonum.org/v1/gonum/mat/vector.go new file mode 100644 index 00000000..4c29c98b --- /dev/null +++ b/vendor/gonum.org/v1/gonum/mat/vector.go @@ -0,0 +1,711 @@ +// Copyright ©2013 The Gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mat + +import ( + "gonum.org/v1/gonum/blas" + "gonum.org/v1/gonum/blas/blas64" + "gonum.org/v1/gonum/internal/asm/f64" +) + +var ( + vector *VecDense + + _ Matrix = vector + _ Vector = vector + _ Reseter = vector +) + +// Vector is a vector. +type Vector interface { + Matrix + AtVec(int) float64 + Len() int +} + +// TransposeVec is a type for performing an implicit transpose of a Vector. +// It implements the Vector interface, returning values from the transpose +// of the vector within. +type TransposeVec struct { + Vector Vector +} + +// At returns the value of the element at row i and column j of the transposed +// matrix, that is, row j and column i of the Vector field. +func (t TransposeVec) At(i, j int) float64 { + return t.Vector.At(j, i) +} + +// Dims returns the dimensions of the transposed vector. +func (t TransposeVec) Dims() (r, c int) { + c, r = t.Vector.Dims() + return r, c +} + +// T performs an implicit transpose by returning the Vector field. +func (t TransposeVec) T() Matrix { + return t.Vector +} + +// Len returns the number of columns in the vector. +func (t TransposeVec) Len() int { + return t.Vector.Len() +} + +// TVec performs an implicit transpose by returning the Vector field. +func (t TransposeVec) TVec() Vector { + return t.Vector +} + +// Untranspose returns the Vector field. +func (t TransposeVec) Untranspose() Matrix { + return t.Vector +} + +func (t TransposeVec) UntransposeVec() Vector { + return t.Vector +} + +// VecDense represents a column vector. +type VecDense struct { + mat blas64.Vector + n int + // A BLAS vector can have a negative increment, but allowing this + // in the mat type complicates a lot of code, and doesn't gain anything. + // VecDense must have positive increment in this package. +} + +// NewVecDense creates a new VecDense of length n. If data == nil, +// a new slice is allocated for the backing slice. If len(data) == n, data is +// used as the backing slice, and changes to the elements of the returned VecDense +// will be reflected in data. If neither of these is true, NewVecDense will panic. +func NewVecDense(n int, data []float64) *VecDense { + if len(data) != n && data != nil { + panic(ErrShape) + } + if data == nil { + data = make([]float64, n) + } + return &VecDense{ + mat: blas64.Vector{ + Inc: 1, + Data: data, + }, + n: n, + } +} + +// SliceVec returns a new Vector that shares backing data with the receiver. +// The returned matrix starts at i of the receiver and extends k-i elements. +// SliceVec panics with ErrIndexOutOfRange if the slice is outside the capacity +// of the receiver. +func (v *VecDense) SliceVec(i, k int) Vector { + if i < 0 || k <= i || v.Cap() < k { + panic(ErrIndexOutOfRange) + } + return &VecDense{ + n: k - i, + mat: blas64.Vector{ + Inc: v.mat.Inc, + Data: v.mat.Data[i*v.mat.Inc : (k-1)*v.mat.Inc+1], + }, + } +} + +// Dims returns the number of rows and columns in the matrix. Columns is always 1 +// for a non-Reset vector. +func (v *VecDense) Dims() (r, c int) { + if v.IsZero() { + return 0, 0 + } + return v.n, 1 +} + +// Caps returns the number of rows and columns in the backing matrix. Columns is always 1 +// for a non-Reset vector. +func (v *VecDense) Caps() (r, c int) { + if v.IsZero() { + return 0, 0 + } + return v.Cap(), 1 +} + +// Len returns the length of the vector. +func (v *VecDense) Len() int { + return v.n +} + +// Cap returns the capacity of the vector. +func (v *VecDense) Cap() int { + if v.IsZero() { + return 0 + } + return (cap(v.mat.Data)-1)/v.mat.Inc + 1 +} + +// T performs an implicit transpose by returning the receiver inside a Transpose. +func (v *VecDense) T() Matrix { + return Transpose{v} +} + +// Reset zeros the length of the vector so that it can be reused as the +// receiver of a dimensionally restricted operation. +// +// See the Reseter interface for more information. +func (v *VecDense) Reset() { + // No change of Inc or n to 0 may be + // made unless both are set to 0. + v.mat.Inc = 0 + v.n = 0 + v.mat.Data = v.mat.Data[:0] +} + +// CloneVec makes a copy of a into the receiver, overwriting the previous value +// of the receiver. +func (v *VecDense) CloneVec(a Vector) { + if v == a { + return + } + v.n = a.Len() + v.mat = blas64.Vector{ + Inc: 1, + Data: use(v.mat.Data, v.n), + } + if r, ok := a.(RawVectorer); ok { + blas64.Copy(v.n, r.RawVector(), v.mat) + return + } + for i := 0; i < a.Len(); i++ { + v.SetVec(i, a.AtVec(i)) + } +} + +// VecDenseCopyOf returns a newly allocated copy of the elements of a. +func VecDenseCopyOf(a Vector) *VecDense { + v := &VecDense{} + v.CloneVec(a) + return v +} + +func (v *VecDense) RawVector() blas64.Vector { + return v.mat +} + +// CopyVec makes a copy of elements of a into the receiver. It is similar to the +// built-in copy; it copies as much as the overlap between the two vectors and +// returns the number of elements it copied. +func (v *VecDense) CopyVec(a Vector) int { + n := min(v.Len(), a.Len()) + if v == a { + return n + } + if r, ok := a.(RawVectorer); ok { + blas64.Copy(n, r.RawVector(), v.mat) + return n + } + for i := 0; i < n; i++ { + v.setVec(i, a.AtVec(i)) + } + return n +} + +// ScaleVec scales the vector a by alpha, placing the result in the receiver. +func (v *VecDense) ScaleVec(alpha float64, a Vector) { + n := a.Len() + + if v == a { + if v.mat.Inc == 1 { + f64.ScalUnitary(alpha, v.mat.Data) + return + } + f64.ScalInc(alpha, v.mat.Data, uintptr(n), uintptr(v.mat.Inc)) + return + } + + v.reuseAs(n) + + if rv, ok := a.(RawVectorer); ok { + mat := rv.RawVector() + v.checkOverlap(mat) + if v.mat.Inc == 1 && mat.Inc == 1 { + f64.ScalUnitaryTo(v.mat.Data, alpha, mat.Data) + return + } + f64.ScalIncTo(v.mat.Data, uintptr(v.mat.Inc), + alpha, mat.Data, uintptr(n), uintptr(mat.Inc)) + return + } + + for i := 0; i < n; i++ { + v.setVec(i, alpha*a.AtVec(i)) + } +} + +// AddScaledVec adds the vectors a and alpha*b, placing the result in the receiver. +func (v *VecDense) AddScaledVec(a Vector, alpha float64, b Vector) { + if alpha == 1 { + v.AddVec(a, b) + return + } + if alpha == -1 { + v.SubVec(a, b) + return + } + + ar := a.Len() + br := b.Len() + + if ar != br { + panic(ErrShape) + } + + var amat, bmat blas64.Vector + fast := true + aU, _ := untranspose(a) + if rv, ok := aU.(RawVectorer); ok { + amat = rv.RawVector() + if v != a { + v.checkOverlap(amat) + } + } else { + fast = false + } + bU, _ := untranspose(b) + if rv, ok := bU.(RawVectorer); ok { + bmat = rv.RawVector() + if v != b { + v.checkOverlap(bmat) + } + } else { + fast = false + } + + v.reuseAs(ar) + + switch { + case alpha == 0: // v <- a + if v == a { + return + } + v.CopyVec(a) + case v == a && v == b: // v <- v + alpha * v = (alpha + 1) * v + blas64.Scal(ar, alpha+1, v.mat) + case !fast: // v <- a + alpha * b without blas64 support. + for i := 0; i < ar; i++ { + v.setVec(i, a.AtVec(i)+alpha*b.AtVec(i)) + } + case v == a && v != b: // v <- v + alpha * b + if v.mat.Inc == 1 && bmat.Inc == 1 { + // Fast path for a common case. + f64.AxpyUnitaryTo(v.mat.Data, alpha, bmat.Data, amat.Data) + } else { + f64.AxpyInc(alpha, bmat.Data, v.mat.Data, + uintptr(ar), uintptr(bmat.Inc), uintptr(v.mat.Inc), 0, 0) + } + default: // v <- a + alpha * b or v <- a + alpha * v + if v.mat.Inc == 1 && amat.Inc == 1 && bmat.Inc == 1 { + // Fast path for a common case. + f64.AxpyUnitaryTo(v.mat.Data, alpha, bmat.Data, amat.Data) + } else { + f64.AxpyIncTo(v.mat.Data, uintptr(v.mat.Inc), 0, + alpha, bmat.Data, amat.Data, + uintptr(ar), uintptr(bmat.Inc), uintptr(amat.Inc), 0, 0) + } + } +} + +// AddVec adds the vectors a and b, placing the result in the receiver. +func (v *VecDense) AddVec(a, b Vector) { + ar := a.Len() + br := b.Len() + + if ar != br { + panic(ErrShape) + } + + v.reuseAs(ar) + + aU, _ := untranspose(a) + bU, _ := untranspose(b) + + if arv, ok := aU.(RawVectorer); ok { + if brv, ok := bU.(RawVectorer); ok { + amat := arv.RawVector() + bmat := brv.RawVector() + + if v != a { + v.checkOverlap(amat) + } + if v != b { + v.checkOverlap(bmat) + } + + if v.mat.Inc == 1 && amat.Inc == 1 && bmat.Inc == 1 { + // Fast path for a common case. + f64.AxpyUnitaryTo(v.mat.Data, 1, bmat.Data, amat.Data) + return + } + f64.AxpyIncTo(v.mat.Data, uintptr(v.mat.Inc), 0, + 1, bmat.Data, amat.Data, + uintptr(ar), uintptr(bmat.Inc), uintptr(amat.Inc), 0, 0) + return + } + } + + for i := 0; i < ar; i++ { + v.setVec(i, a.AtVec(i)+b.AtVec(i)) + } +} + +// SubVec subtracts the vector b from a, placing the result in the receiver. +func (v *VecDense) SubVec(a, b Vector) { + ar := a.Len() + br := b.Len() + + if ar != br { + panic(ErrShape) + } + + v.reuseAs(ar) + + aU, _ := untranspose(a) + bU, _ := untranspose(b) + + if arv, ok := aU.(RawVectorer); ok { + if brv, ok := bU.(RawVectorer); ok { + amat := arv.RawVector() + bmat := brv.RawVector() + + if v != a { + v.checkOverlap(amat) + } + if v != b { + v.checkOverlap(bmat) + } + + if v.mat.Inc == 1 && amat.Inc == 1 && bmat.Inc == 1 { + // Fast path for a common case. + f64.AxpyUnitaryTo(v.mat.Data, -1, bmat.Data, amat.Data) + return + } + f64.AxpyIncTo(v.mat.Data, uintptr(v.mat.Inc), 0, + -1, bmat.Data, amat.Data, + uintptr(ar), uintptr(bmat.Inc), uintptr(amat.Inc), 0, 0) + return + } + } + + for i := 0; i < ar; i++ { + v.setVec(i, a.AtVec(i)-b.AtVec(i)) + } +} + +// MulElemVec performs element-wise multiplication of a and b, placing the result +// in the receiver. +func (v *VecDense) MulElemVec(a, b Vector) { + ar := a.Len() + br := b.Len() + + if ar != br { + panic(ErrShape) + } + + v.reuseAs(ar) + + aU, _ := untranspose(a) + bU, _ := untranspose(b) + + if arv, ok := aU.(RawVectorer); ok { + if brv, ok := bU.(RawVectorer); ok { + amat := arv.RawVector() + bmat := brv.RawVector() + + if v != a { + v.checkOverlap(amat) + } + if v != b { + v.checkOverlap(bmat) + } + + if v.mat.Inc == 1 && amat.Inc == 1 && bmat.Inc == 1 { + // Fast path for a common case. + for i, a := range amat.Data { + v.mat.Data[i] = a * bmat.Data[i] + } + return + } + var ia, ib int + for i := 0; i < ar; i++ { + v.setVec(i, amat.Data[ia]*bmat.Data[ib]) + ia += amat.Inc + ib += bmat.Inc + } + return + } + } + + for i := 0; i < ar; i++ { + v.setVec(i, a.AtVec(i)*b.AtVec(i)) + } +} + +// DivElemVec performs element-wise division of a by b, placing the result +// in the receiver. +func (v *VecDense) DivElemVec(a, b Vector) { + ar := a.Len() + br := b.Len() + + if ar != br { + panic(ErrShape) + } + + v.reuseAs(ar) + + aU, _ := untranspose(a) + bU, _ := untranspose(b) + + if arv, ok := aU.(RawVectorer); ok { + if brv, ok := bU.(RawVectorer); ok { + amat := arv.RawVector() + bmat := brv.RawVector() + + if v != a { + v.checkOverlap(amat) + } + if v != b { + v.checkOverlap(bmat) + } + + if v.mat.Inc == 1 && amat.Inc == 1 && bmat.Inc == 1 { + // Fast path for a common case. + for i, a := range amat.Data { + v.setVec(i, a/bmat.Data[i]) + } + return + } + var ia, ib int + for i := 0; i < ar; i++ { + v.setVec(i, amat.Data[ia]/bmat.Data[ib]) + ia += amat.Inc + ib += bmat.Inc + } + } + } + + for i := 0; i < ar; i++ { + v.setVec(i, a.AtVec(i)/b.AtVec(i)) + } +} + +// MulVec computes a * b. The result is stored into the receiver. +// MulVec panics if the number of columns in a does not equal the number of rows in b +// or if the number of columns in b does not equal 1. +func (v *VecDense) MulVec(a Matrix, b Vector) { + r, c := a.Dims() + br, bc := b.Dims() + if c != br || bc != 1 { + panic(ErrShape) + } + + aU, trans := untranspose(a) + var bmat blas64.Vector + fast := true + bU, _ := untranspose(b) + if rv, ok := bU.(RawVectorer); ok { + bmat = rv.RawVector() + if v != b { + v.checkOverlap(bmat) + } + } else { + fast = false + } + + v.reuseAs(r) + var restore func() + if v == aU { + v, restore = v.isolatedWorkspace(aU.(*VecDense)) + defer restore() + } else if v == b { + v, restore = v.isolatedWorkspace(b) + defer restore() + } + + // TODO(kortschak): Improve the non-fast paths. + switch aU := aU.(type) { + case Vector: + if b.Len() == 1 { + // {n,1} x {1,1} + v.ScaleVec(b.AtVec(0), aU) + return + } + + // {1,n} x {n,1} + if fast { + if rv, ok := aU.(RawVectorer); ok { + amat := rv.RawVector() + if v != aU { + v.checkOverlap(amat) + } + + if amat.Inc == 1 && bmat.Inc == 1 { + // Fast path for a common case. + v.setVec(0, f64.DotUnitary(amat.Data, bmat.Data)) + return + } + v.setVec(0, f64.DotInc(amat.Data, bmat.Data, + uintptr(c), uintptr(amat.Inc), uintptr(bmat.Inc), 0, 0)) + return + } + } + var sum float64 + for i := 0; i < c; i++ { + sum += aU.AtVec(i) * b.AtVec(i) + } + v.setVec(0, sum) + return + case RawSymmetricer: + if fast { + amat := aU.RawSymmetric() + // We don't know that a is a *SymDense, so make + // a temporary SymDense to check overlap. + (&SymDense{mat: amat}).checkOverlap(v.asGeneral()) + blas64.Symv(1, amat, bmat, 0, v.mat) + return + } + case RawTriangular: + v.CopyVec(b) + amat := aU.RawTriangular() + // We don't know that a is a *TriDense, so make + // a temporary TriDense to check overlap. + (&TriDense{mat: amat}).checkOverlap(v.asGeneral()) + ta := blas.NoTrans + if trans { + ta = blas.Trans + } + blas64.Trmv(ta, amat, v.mat) + case RawMatrixer: + if fast { + amat := aU.RawMatrix() + // We don't know that a is a *Dense, so make + // a temporary Dense to check overlap. + (&Dense{mat: amat}).checkOverlap(v.asGeneral()) + t := blas.NoTrans + if trans { + t = blas.Trans + } + blas64.Gemv(t, 1, amat, bmat, 0, v.mat) + return + } + default: + if fast { + for i := 0; i < r; i++ { + var f float64 + for j := 0; j < c; j++ { + f += a.At(i, j) * bmat.Data[j*bmat.Inc] + } + v.setVec(i, f) + } + return + } + } + + for i := 0; i < r; i++ { + var f float64 + for j := 0; j < c; j++ { + f += a.At(i, j) * b.AtVec(j) + } + v.setVec(i, f) + } +} + +// reuseAs resizes an empty vector to a r×1 vector, +// or checks that a non-empty matrix is r×1. +func (v *VecDense) reuseAs(r int) { + if v.IsZero() { + v.mat = blas64.Vector{ + Inc: 1, + Data: use(v.mat.Data, r), + } + v.n = r + return + } + if r != v.n { + panic(ErrShape) + } +} + +// IsZero returns whether the receiver is zero-sized. Zero-sized vectors can be the +// receiver for size-restricted operations. VecDenses can be zeroed using Reset. +func (v *VecDense) IsZero() bool { + // It must be the case that v.Dims() returns + // zeros in this case. See comment in Reset(). + return v.mat.Inc == 0 +} + +func (v *VecDense) isolatedWorkspace(a Vector) (n *VecDense, restore func()) { + l := a.Len() + n = getWorkspaceVec(l, false) + return n, func() { + v.CopyVec(n) + putWorkspaceVec(n) + } +} + +// asDense returns a Dense representation of the receiver with the same +// underlying data. +func (v *VecDense) asDense() *Dense { + return &Dense{ + mat: v.asGeneral(), + capRows: v.n, + capCols: 1, + } +} + +// asGeneral returns a blas64.General representation of the receiver with the +// same underlying data. +func (v *VecDense) asGeneral() blas64.General { + return blas64.General{ + Rows: v.n, + Cols: 1, + Stride: v.mat.Inc, + Data: v.mat.Data, + } +} + +// ColViewOf reflects the column j of the RawMatrixer m, into the receiver +// backed by the same underlying data. The length of the receiver must either be +// zero or match the number of rows in m. +func (v *VecDense) ColViewOf(m RawMatrixer, j int) { + rm := m.RawMatrix() + + if j >= rm.Cols || j < 0 { + panic(ErrColAccess) + } + if !v.IsZero() && v.n != rm.Rows { + panic(ErrShape) + } + + v.mat.Inc = rm.Stride + v.mat.Data = rm.Data[j : (rm.Rows-1)*rm.Stride+j+1] + v.n = rm.Rows +} + +// RowViewOf reflects the row i of the RawMatrixer m, into the receiver +// backed by the same underlying data. The length of the receiver must either be +// zero or match the number of columns in m. +func (v *VecDense) RowViewOf(m RawMatrixer, i int) { + rm := m.RawMatrix() + + if i >= rm.Rows || i < 0 { + panic(ErrRowAccess) + } + if !v.IsZero() && v.n != rm.Cols { + panic(ErrShape) + } + + v.mat.Inc = 1 + v.mat.Data = rm.Data[i*rm.Stride : i*rm.Stride+rm.Cols] + v.n = rm.Cols +} diff --git a/vendor/github.com/gonum/plot/LICENSE b/vendor/gonum.org/v1/plot/LICENSE similarity index 100% rename from vendor/github.com/gonum/plot/LICENSE rename to vendor/gonum.org/v1/plot/LICENSE diff --git a/vendor/gonum.org/v1/plot/align.go b/vendor/gonum.org/v1/plot/align.go new file mode 100644 index 00000000..523965ff --- /dev/null +++ b/vendor/gonum.org/v1/plot/align.go @@ -0,0 +1,117 @@ +// Copyright ©2017 The gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package plot + +import ( + "fmt" + "math" + + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" +) + +// Align returns a two-dimensional row-major array of Canvases which will +// produce tiled plots with DataCanvases that are evenly sized and spaced. +// The arguments to the function are a two-dimensional row-major array +// of plots, a tile configuration, and the canvas to which the tiled +// plots are to be drawn. +func Align(plots [][]*Plot, t draw.Tiles, dc draw.Canvas) [][]draw.Canvas { + o := make([][]draw.Canvas, len(plots)) + + if len(plots) != t.Rows { + panic(fmt.Errorf("plot: plots rows (%d) != tiles rows (%d)", len(plots), t.Rows)) + } + + // Create the initial tiles. + for j := 0; j < t.Rows; j++ { + if len(plots[j]) != t.Cols { + panic(fmt.Errorf("plot: plots row %d columns (%d) != tiles columns (%d)", j, len(plots[j]), t.Rows)) + } + + o[j] = make([]draw.Canvas, len(plots[j])) + for i := 0; i < t.Cols; i++ { + o[j][i] = t.At(dc, i, j) + } + } + + type posNeg struct { + p, n float64 + } + xSpacing := make([]posNeg, t.Cols) + ySpacing := make([]posNeg, t.Rows) + + // Calculate the maximum spacing between data canvases + // for each row and column. + for j, row := range plots { + for i, p := range row { + if p == nil { + continue + } + c := o[j][i] + dataC := p.DataCanvas(o[j][i]) + xSpacing[i].n = math.Max(float64(dataC.Min.X-c.Min.X), xSpacing[i].n) + xSpacing[i].p = math.Max(float64(c.Max.X-dataC.Max.X), xSpacing[i].p) + ySpacing[j].n = math.Max(float64(dataC.Min.Y-c.Min.Y), ySpacing[j].n) + ySpacing[j].p = math.Max(float64(c.Max.Y-dataC.Max.Y), ySpacing[j].p) + } + } + + // Calculate the total row and column spacing. + var xTotalSpace float64 + for _, s := range xSpacing { + xTotalSpace += s.n + s.p + } + var yTotalSpace float64 + for _, s := range ySpacing { + yTotalSpace += s.n + s.p + } + + avgWidth := vg.Length((float64(dc.Max.X-dc.Min.X) - xTotalSpace) / float64(t.Cols)) + avgHeight := vg.Length((float64(dc.Max.Y-dc.Min.Y) - yTotalSpace) / float64(t.Rows)) + + moveVertical := make([]vg.Length, t.Cols) + for j := t.Rows - 1; j >= 0; j-- { + row := plots[j] + var moveHorizontal vg.Length + for i, p := range row { + c := o[j][i] + + if p != nil { + dataC := p.DataCanvas(c) + // Adjust the horizontal and vertical spacing between + // canvases to match the maximum for each column and row, + // respectively. + c = draw.Crop(c, + vg.Length(xSpacing[i].n)-(dataC.Min.X-c.Min.X), + c.Max.X-dataC.Max.X-vg.Length(xSpacing[i].p), + vg.Length(ySpacing[j].n)-(dataC.Min.Y-c.Min.Y), + c.Max.Y-dataC.Max.Y-vg.Length(ySpacing[j].p), + ) + } + + var width, height vg.Length + if p == nil { + width = c.Max.X - c.Min.X - vg.Length(xSpacing[i].p+xSpacing[i].n) + height = c.Max.Y - c.Min.Y - vg.Length(ySpacing[j].p+ySpacing[j].n) + } else { + dataC := p.DataCanvas(c) + width = dataC.Max.X - dataC.Min.X + height = dataC.Max.Y - dataC.Min.Y + } + + // Adjust the canvas so that the height and width of the + // DataCanvas is the same for all plots. + o[j][i] = draw.Crop(c, + moveHorizontal, + moveHorizontal+avgWidth-width, + moveVertical[i], + moveVertical[i]+avgHeight-height, + ) + moveHorizontal += avgWidth - width + moveVertical[i] += avgHeight - height + } + } + return o +} diff --git a/vendor/github.com/gonum/plot/axis.go b/vendor/gonum.org/v1/plot/axis.go similarity index 82% rename from vendor/github.com/gonum/plot/axis.go rename to vendor/gonum.org/v1/plot/axis.go index d1f13743..93be3b14 100644 --- a/vendor/github.com/gonum/plot/axis.go +++ b/vendor/gonum.org/v1/plot/axis.go @@ -10,14 +10,10 @@ import ( "strconv" "time" - "github.com/gonum/floats" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) -// displayPrecision is a sane level of float precision for a plot. -const displayPrecision = 4 - // Ticker creates Ticks in a specified range type Ticker interface { // Ticks returns Ticks in a specified range @@ -179,12 +175,12 @@ func (LogScale) Normalize(min, max, x float64) float64 { // system, normalized to its distance as a fraction of the // range of this axis. For example, if x is a.Min then the return // value is 0, and if x is a.Max then the return value is 1. -func (a *Axis) Norm(x float64) float64 { +func (a Axis) Norm(x float64) float64 { return a.Scale.Normalize(a.Min, a.Max, x) } // drawTicks returns true if the tick marks should be drawn. -func (a *Axis) drawTicks() bool { +func (a Axis) drawTicks() bool { return a.Tick.Width > 0 && a.Tick.Length > 0 } @@ -195,12 +191,14 @@ type horizontalAxis struct { } // size returns the height of the axis. -func (a *horizontalAxis) size() (h vg.Length) { +func (a horizontalAxis) size() (h vg.Length) { if a.Label.Text != "" { // We assume that the label isn't rotated. h -= a.Label.Font.Extents().Descent h += a.Label.Height(a.Label.Text) } - if marks := a.Tick.Marker.Ticks(a.Min, a.Max); len(marks) > 0 { + + marks := a.Tick.Marker.Ticks(a.Min, a.Max) + if len(marks) > 0 { if a.drawTicks() { h += a.Tick.Length } @@ -208,11 +206,12 @@ func (a *horizontalAxis) size() (h vg.Length) { } h += a.Width / 2 h += a.Padding - return + + return h } // draw draws the axis along the lower edge of a draw.Canvas. -func (a *horizontalAxis) draw(c draw.Canvas) { +func (a horizontalAxis) draw(c draw.Canvas) { y := c.Min.Y if a.Label.Text != "" { y -= a.Label.Font.Extents().Descent @@ -253,7 +252,8 @@ func (a *horizontalAxis) draw(c draw.Canvas) { } // GlyphBoxes returns the GlyphBoxes for the tick labels. -func (a *horizontalAxis) GlyphBoxes(*Plot) (boxes []GlyphBox) { +func (a horizontalAxis) GlyphBoxes(*Plot) []GlyphBox { + var boxes []GlyphBox for _, t := range a.Tick.Marker.Ticks(a.Min, a.Max) { if t.IsMinor() { continue @@ -264,7 +264,7 @@ func (a *horizontalAxis) GlyphBoxes(*Plot) (boxes []GlyphBox) { } boxes = append(boxes, box) } - return + return boxes } // A verticalAxis is drawn vertically up the left side of a plot. @@ -273,12 +273,14 @@ type verticalAxis struct { } // size returns the width of the axis. -func (a *verticalAxis) size() (w vg.Length) { +func (a verticalAxis) size() (w vg.Length) { if a.Label.Text != "" { // We assume that the label isn't rotated. w -= a.Label.Font.Extents().Descent w += a.Label.Height(a.Label.Text) } - if marks := a.Tick.Marker.Ticks(a.Min, a.Max); len(marks) > 0 { + + marks := a.Tick.Marker.Ticks(a.Min, a.Max) + if len(marks) > 0 { if lwidth := tickLabelWidth(a.Tick.Label, marks); lwidth > 0 { w += lwidth w += a.Label.Width(" ") @@ -289,11 +291,12 @@ func (a *verticalAxis) size() (w vg.Length) { } w += a.Width / 2 w += a.Padding - return + + return w } // draw draws the axis along the left side of a draw.Canvas. -func (a *verticalAxis) draw(c draw.Canvas) { +func (a verticalAxis) draw(c draw.Canvas) { x := c.Min.X if a.Label.Text != "" { sty := a.Label.TextStyle @@ -306,6 +309,7 @@ func (a *verticalAxis) draw(c draw.Canvas) { if w := tickLabelWidth(a.Tick.Label, marks); len(marks) > 0 && w > 0 { x += w } + major := false for _, t := range marks { y := c.Y(a.Norm(t.Value)) @@ -330,11 +334,13 @@ func (a *verticalAxis) draw(c draw.Canvas) { } x += len } + c.StrokeLine2(a.LineStyle, x, c.Min.Y, x, c.Max.Y) } // GlyphBoxes returns the GlyphBoxes for the tick labels -func (a *verticalAxis) GlyphBoxes(*Plot) (boxes []GlyphBox) { +func (a verticalAxis) GlyphBoxes(*Plot) []GlyphBox { + var boxes []GlyphBox for _, t := range a.Tick.Marker.Ticks(a.Min, a.Max) { if t.IsMinor() { continue @@ -345,73 +351,103 @@ func (a *verticalAxis) GlyphBoxes(*Plot) (boxes []GlyphBox) { } boxes = append(boxes, box) } - return + return boxes } // DefaultTicks is suitable for the Tick.Marker field of an Axis, -// it returns a resonable default set of tick marks. +// it returns a reasonable default set of tick marks. type DefaultTicks struct{} var _ Ticker = DefaultTicks{} -// Ticks returns Ticks in a specified range -func (DefaultTicks) Ticks(min, max float64) (ticks []Tick) { - const SuggestedTicks = 3 - if max < min { +// Ticks returns Ticks in the specified range. +func (DefaultTicks) Ticks(min, max float64) []Tick { + if max <= min { panic("illegal range") } - tens := math.Pow10(int(math.Floor(math.Log10(max - min)))) - n := (max - min) / tens - for n < SuggestedTicks { - tens /= 10 - n = (max - min) / tens + + const suggestedTicks = 3 + + labels, step, q, mag := talbotLinHanrahan(min, max, suggestedTicks, withinData, nil, nil, nil) + majorDelta := step * math.Pow10(mag) + if q == 0 { + // Simple fall back was chosen, so + // majorDelta is the label distance. + majorDelta = labels[1] - labels[0] } - majorMult := int(n / SuggestedTicks) - switch majorMult { - case 7: - majorMult = 6 - case 9: - majorMult = 8 + // Choose a reasonable, but ad + // hoc formatting for labels. + fc := byte('f') + var off int + if mag < -1 || 6 < mag { + off = 1 + fc = 'g' } - majorDelta := float64(majorMult) * tens - val := math.Floor(min/majorDelta) * majorDelta - prec := precisionOf(majorDelta) - for val <= max { - if val >= min && val <= max { - ticks = append(ticks, Tick{Value: val, Label: formatFloatTick(val, prec)}) + if math.Trunc(q) != q { + off += 2 + } + prec := minInt(6, maxInt(off, -mag)) + var ticks []Tick + for _, v := range labels { + ticks = append(ticks, Tick{Value: v, Label: strconv.FormatFloat(v, fc, prec, 64)}) + } + + var minorDelta float64 + // See talbotLinHanrahan for the values used here. + switch step { + case 1, 2.5: + minorDelta = majorDelta / 5 + case 2, 3, 4, 5: + minorDelta = majorDelta / step + default: + if majorDelta/2 < dlamchP { + return ticks } - if math.Nextafter(val, val+majorDelta) == val { + minorDelta = majorDelta / 2 + } + + // Find the first minor tick not greater + // than the lowest data value. + var i float64 + for labels[0]+(i-1)*minorDelta > min { + i-- + } + // Add ticks at minorDelta intervals when + // they are not within minorDelta/2 of a + // labelled tick. + for { + val := labels[0] + i*minorDelta + if val > max { break } - val += majorDelta - } - - minorDelta := majorDelta / 2 - switch majorMult { - case 3, 6: - minorDelta = majorDelta / 3 - case 5: - minorDelta = majorDelta / 5 - } - - val = math.Floor(min/minorDelta) * minorDelta - for val <= max { found := false for _, t := range ticks { - if t.Value == val { + if math.Abs(t.Value-val) < minorDelta/2 { found = true } } - if val >= min && val <= max && !found { + if !found { ticks = append(ticks, Tick{Value: val}) } - if math.Nextafter(val, val+minorDelta) == val { - break - } - val += minorDelta + i++ } - return + + return ticks +} + +func minInt(a, b int) int { + if a < b { + return a + } + return b +} + +func maxInt(a, b int) int { + if a > b { + return a + } + return b } // LogTicks is suitable for the Tick.Marker field of an Axis, @@ -422,24 +458,24 @@ var _ Ticker = LogTicks{} // Ticks returns Ticks in a specified range func (LogTicks) Ticks(min, max float64) []Tick { - var ticks []Tick - val := math.Pow10(int(math.Floor(math.Log10(min)))) if min <= 0 { panic("Values must be greater than 0 for a log scale.") } - prec := precisionOf(max) - for val < max*10 { + + val := math.Pow10(int(math.Log10(min))) + max = math.Pow10(int(math.Ceil(math.Log10(max)))) + var ticks []Tick + for val < max { for i := 1; i < 10; i++ { - tick := Tick{Value: val * float64(i)} if i == 1 { - tick.Label = formatFloatTick(val*float64(i), prec) + ticks = append(ticks, Tick{Value: val, Label: formatFloatTick(val, -1)}) } - ticks = append(ticks, tick) + ticks = append(ticks, Tick{Value: val * float64(i)}) } val *= 10 } - tick := Tick{Value: val, Label: formatFloatTick(val, prec)} - ticks = append(ticks, tick) + ticks = append(ticks, Tick{Value: val, Label: formatFloatTick(val, -1)}) + return ticks } @@ -573,10 +609,5 @@ func log(x float64) float64 { // formatFloatTick returns a g-formated string representation of v // to the specified precision. func formatFloatTick(v float64, prec int) string { - return strconv.FormatFloat(floats.Round(v, prec), 'g', displayPrecision, 64) -} - -// precisionOf returns the precision needed to display x without e notation. -func precisionOf(x float64) int { - return int(math.Max(math.Ceil(-math.Log10(math.Abs(x))), displayPrecision)) + return strconv.FormatFloat(v, 'g', prec, 64) } diff --git a/vendor/gonum.org/v1/plot/doc.go b/vendor/gonum.org/v1/plot/doc.go new file mode 100644 index 00000000..61d0c253 --- /dev/null +++ b/vendor/gonum.org/v1/plot/doc.go @@ -0,0 +1,16 @@ +// Copyright ©2017 The gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package plot provides an API for setting up plots, and primitives for +// drawing on plots. +// +// Plot is the basic type for creating a plot, setting the title, axis +// labels, legend, tick marks, etc. Types implementing the Plotter +// interface can draw to the data area of a plot using the primitives +// made available by this package. Some standard implementations +// of the Plotter interface can be found in the +// gonum.org/v1/plot/plotter package +// which is documented here: +// https://godoc.org/gonum.org/v1/plot/plotter +package plot // import "gonum.org/v1/plot" diff --git a/vendor/gonum.org/v1/plot/labelling.go b/vendor/gonum.org/v1/plot/labelling.go new file mode 100644 index 00000000..82a5a676 --- /dev/null +++ b/vendor/gonum.org/v1/plot/labelling.go @@ -0,0 +1,274 @@ +// Copyright ©2017 The gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This is an implementation of the Talbot, Lin and Hanrahan algorithm +// described in doi:10.1109/TVCG.2010.130 with reference to the R +// implementation in the labeling package, ©2014 Justin Talbot (Licensed +// MIT+file LICENSE|Unlimited). + +package plot + +import ( + "math" +) + +const ( + // dlamchE is the machine epsilon. For IEEE this is 2^{-53}. + dlamchE = 1.0 / (1 << 53) + + // dlamchB is the radix of the machine (the base of the number system). + dlamchB = 2 + + // dlamchP is base * eps. + dlamchP = dlamchB * dlamchE +) + +const ( + // free indicates no restriction on label containment. + free = iota + // containData specifies that all the data range lies + // within the interval [label_min, label_max]. + containData + // withinData specifies that all labels lie within the + // interval [dMin, dMax]. + withinData +) + +// talbotLinHanrahan returns an optimal set of approximately want label values +// for the data range [dMin, dMax], and the step and magnitude of the step between values. +// containment is specifies are guarantees for label and data range containment, valid +// values are free, containData and withinData. +// The optional parameters Q, nice numbers, and w, weights, allow tuning of the +// algorithm but by default (when nil) are set to the parameters described in the +// paper. +// The legibility function allows tuning of the legibility assessment for labels. +// By default, when nil, legbility will set the legibility score for each candidate +// labelling scheme to 1. +// See the paper for an explanation of the function of Q, w and legibility. +func talbotLinHanrahan(dMin, dMax float64, want int, containment int, Q []float64, w *weights, legibility func(lMin, lMax, lStep float64) float64) (values []float64, step, q float64, magnitude int) { + const eps = dlamchP * 100 + + if dMin > dMax { + panic("labelling: invalid data range: min greater than max") + } + + if Q == nil { + Q = []float64{1, 5, 2, 2.5, 4, 3} + } + if w == nil { + w = &weights{ + simplicity: 0.25, + coverage: 0.2, + density: 0.5, + legibility: 0.05, + } + } + if legibility == nil { + legibility = unitLegibility + } + + if r := dMax - dMin; r < eps { + l := make([]float64, want) + step := r / float64(want-1) + for i := range l { + l[i] = dMin + float64(i)*step + } + magnitude = minAbsMag(dMin, dMax) + return l, step, 0, magnitude + } + + type selection struct { + // n is the number of labels selected. + n int + // lMin and lMax are the selected min + // and max label values. lq is the q + // chosen. + lMin, lMax, lStep, lq float64 + // score is the score for the selection. + score float64 + // magnitude is the magnitude of the + // label step distance. + magnitude int + } + best := selection{score: -2} + +outer: + for skip := 1; ; skip++ { + for _, q := range Q { + sm := maxSimplicity(q, Q, skip) + if w.score(sm, 1, 1, 1) < best.score { + break outer + } + + for have := 2; ; have++ { + dm := maxDensity(have, want) + if w.score(sm, 1, dm, 1) < best.score { + break + } + + delta := (dMax - dMin) / float64(have+1) / float64(skip) / q + + const maxExp = 309 + for mag := int(math.Ceil(math.Log10(delta))); mag < maxExp; mag++ { + step := float64(skip) * q * math.Pow10(mag) + + cm := maxCoverage(dMin, dMax, step*float64(have-1)) + if w.score(sm, cm, dm, 1) < best.score { + break + } + + fracStep := step / float64(skip) + kStep := step * float64(have-1) + + minStart := (math.Floor(dMax/step) - float64(have-1)) * float64(skip) + maxStart := math.Ceil(dMax/step) * float64(skip) + for start := minStart; start <= maxStart; start++ { + lMin := start * fracStep + lMax := lMin + kStep + + switch containment { + case containData: + if dMin < lMin || lMax < dMax { + continue + } + case withinData: + if lMin < dMin || dMax < lMax { + continue + } + case free: + // Free choice. + } + + score := w.score( + simplicity(q, Q, skip, lMin, lMax, step), + coverage(dMin, dMax, lMin, lMax), + density(have, want, dMin, dMax, lMin, lMax), + legibility(lMin, lMax, step), + ) + if score > best.score { + best = selection{ + n: have, + lMin: lMin, + lMax: lMax, + lStep: float64(skip) * q, + lq: q, + score: score, + magnitude: mag, + } + } + } + } + } + } + } + + if best.score == -2 { + l := make([]float64, want) + step := (dMax - dMin) / float64(want-1) + for i := range l { + l[i] = dMin + float64(i)*step + } + magnitude = minAbsMag(dMin, dMax) + return l, step, 0, magnitude + } + + l := make([]float64, best.n) + step = best.lStep * math.Pow10(best.magnitude) + for i := range l { + l[i] = best.lMin + float64(i)*step + } + return l, best.lStep, best.lq, best.magnitude +} + +// minAbsMag returns the minumum magnitude of the absolute values of a and b. +func minAbsMag(a, b float64) int { + return int(math.Min(math.Floor(math.Log10(math.Abs(a))), (math.Floor(math.Log10(math.Abs(b)))))) +} + +// simplicity returns the simplicity score for how will the curent q, lMin, lMax, +// lStep and skip match the given nice numbers, Q. +func simplicity(q float64, Q []float64, skip int, lMin, lMax, lStep float64) float64 { + const eps = dlamchP * 100 + + for i, v := range Q { + if v == q { + m := math.Mod(lMin, lStep) + v = 0 + if (m < eps || lStep-m < eps) && lMin <= 0 && 0 <= lMax { + v = 1 + } + return 1 - float64(i)/(float64(len(Q))-1) - float64(skip) + v + } + } + panic("labelling: invalid q for Q") +} + +// maxSimplicity returns the maximum simplicity for q, Q and skip. +func maxSimplicity(q float64, Q []float64, skip int) float64 { + for i, v := range Q { + if v == q { + return 1 - float64(i)/(float64(len(Q))-1) - float64(skip) + 1 + } + } + panic("labelling: invalid q for Q") +} + +// coverage returns the coverage score for based on the average +// squared distance between the extreme labels, lMin and lMax, and +// the extreme data points, dMin and dMax. +func coverage(dMin, dMax, lMin, lMax float64) float64 { + r := 0.1 * (dMax - dMin) + max := dMax - lMax + min := dMin - lMin + return 1 - 0.5*(max*max+min*min)/(r*r) +} + +// maxCoverage returns the maximum coverage achievable for the data +// range. +func maxCoverage(dMin, dMax, span float64) float64 { + r := dMax - dMin + if span <= r { + return 1 + } + h := 0.5 * (span - r) + r *= 0.1 + return 1 - (h*h)/(r*r) +} + +// density returns the density score which measures the goodness of +// the labelling density compared to the user defined target +// based on the want parameter given to talbotLinHanrahan. +func density(have, want int, dMin, dMax, lMin, lMax float64) float64 { + rho := float64(have-1) / (lMax - lMin) + rhot := float64(want-1) / (math.Max(lMax, dMax) - math.Min(dMin, lMin)) + if d := rho / rhot; d >= 1 { + return 2 - d + } + return 2 - rhot/rho +} + +// maxDensity returns the maximum density score achievable for have and want. +func maxDensity(have, want int) float64 { + if have < want { + return 1 + } + return 2 - float64(have-1)/float64(want-1) +} + +// unitLegibility returns a default legibility score ignoring label +// spacing. +func unitLegibility(_, _, _ float64) float64 { + return 1 +} + +// weights is a helper type to calcuate the labelling scheme's total score. +type weights struct { + simplicity, coverage, density, legibility float64 +} + +// score returns the score for a labelling scheme with simplicity, s, +// coverage, c, density, d and legibility l. +func (w *weights) score(s, c, d, l float64) float64 { + return w.simplicity*s + w.coverage*c + w.density*d + w.legibility*l +} diff --git a/vendor/github.com/gonum/plot/legend.go b/vendor/gonum.org/v1/plot/legend.go similarity index 97% rename from vendor/github.com/gonum/plot/legend.go rename to vendor/gonum.org/v1/plot/legend.go index 11ff492e..69e51144 100644 --- a/vendor/github.com/gonum/plot/legend.go +++ b/vendor/gonum.org/v1/plot/legend.go @@ -5,8 +5,8 @@ package plot import ( - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // A Legend gives a description of the meaning of different @@ -19,7 +19,7 @@ type Legend struct { draw.TextStyle // Padding is the amount of padding to add - // betweeneach entry of the legend. If Padding + // between each entry in the legend. If Padding // is zero then entries are spaced based on the // font size. Padding vg.Length diff --git a/vendor/github.com/gonum/plot/palette/hsva.go b/vendor/gonum.org/v1/plot/palette/hsva.go similarity index 100% rename from vendor/github.com/gonum/plot/palette/hsva.go rename to vendor/gonum.org/v1/plot/palette/hsva.go diff --git a/vendor/github.com/gonum/plot/palette/palette.go b/vendor/gonum.org/v1/plot/palette/palette.go similarity index 99% rename from vendor/github.com/gonum/plot/palette/palette.go rename to vendor/gonum.org/v1/plot/palette/palette.go index 3f86c6a5..034c74e9 100644 --- a/vendor/github.com/gonum/plot/palette/palette.go +++ b/vendor/gonum.org/v1/plot/palette/palette.go @@ -7,7 +7,7 @@ // license that can be found in the LICENSE file. // Package palette provides basic color palette handling. -package palette +package palette // import "gonum.org/v1/plot/palette" import ( "errors" diff --git a/vendor/gonum.org/v1/plot/palette/reverse.go b/vendor/gonum.org/v1/plot/palette/reverse.go new file mode 100644 index 00000000..794f1a65 --- /dev/null +++ b/vendor/gonum.org/v1/plot/palette/reverse.go @@ -0,0 +1,35 @@ +// Copyright ©2017 The gonum Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package palette + +import ( + "image/color" +) + +// Reverse reverses the direction of ColorMap c. +func Reverse(c ColorMap) ColorMap { + return reverse{ColorMap: c} +} + +// reverse is a ColorMap that reverses the direction of the ColorMap it +// contains. +type reverse struct { + ColorMap +} + +// At implements the ColorMap interface for a Reversed ColorMap. +func (r reverse) At(v float64) (color.Color, error) { + return r.ColorMap.At(r.Max() - (v - r.Min())) +} + +// Palette implements the ColorMap interface for a Reversed ColorMap. +func (r reverse) Palette(colors int) Palette { + c := r.ColorMap.Palette(colors).Colors() + c2 := make([]color.Color, len(c)) + for i, j := 0, len(c)-1; i < j; i, j = i+1, j-1 { + c2[i], c2[j] = c[j], c[i] + } + return palette(c2) +} diff --git a/vendor/github.com/gonum/plot/plot.go b/vendor/gonum.org/v1/plot/plot.go similarity index 93% rename from vendor/github.com/gonum/plot/plot.go rename to vendor/gonum.org/v1/plot/plot.go index 27b86530..01ee57d9 100644 --- a/vendor/github.com/gonum/plot/plot.go +++ b/vendor/gonum.org/v1/plot/plot.go @@ -2,17 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package plot provides an API for setting up plots, and primitives for -// drawing on plots. -// -// Plot is the basic type for creating a plot, setting the title, axis -// labels, legend, tick marks, etc. Types implementing the Plotter -// interface can draw to the data area of a plot using the primitives -// made available by this package. Some standard implementations -// of the Plotter interface can be found in the -// github.com/gonum/plot/plotter package -// which is documented here: -// http://godoc.org/github.com/gonum/plot/plotter package plot import ( @@ -23,8 +12,8 @@ import ( "path/filepath" "strings" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) var ( @@ -66,9 +55,9 @@ type Plot struct { // Plotter is an interface that wraps the Plot method. // Some standard implementations of Plotter can be -// found in the github.com/gonum/plot/plotter +// found in the gonum.org/v1/plot/plotter // package, documented here: -// http://godoc.org/github.com/gonum/plot/plotter +// https://godoc.org/gonum.org/v1/plot/plotter type Plotter interface { // Plot draws the data to a draw.Canvas. Plot(draw.Canvas, *Plot) @@ -166,8 +155,9 @@ func (p *Plot) Draw(c draw.Canvas) { y := verticalAxis{p.Y} ywidth := y.size() - x.draw(padX(p, draw.Crop(c, ywidth, 0, 0, 0))) + xheight := x.size() + x.draw(padX(p, draw.Crop(c, ywidth, 0, 0, 0))) y.draw(padY(p, draw.Crop(c, 0, 0, xheight, 0))) dataC := padY(p, padX(p, draw.Crop(c, ywidth, 0, xheight, 0))) @@ -175,7 +165,7 @@ func (p *Plot) Draw(c draw.Canvas) { data.Plot(dataC, p) } - p.Legend.draw(draw.Crop(draw.Crop(c, ywidth, 0, 0, 0), 0, 0, xheight, 0)) + p.Legend.draw(draw.Crop(c, ywidth, 0, xheight, 0)) } // DataCanvas returns a new draw.Canvas that @@ -190,7 +180,7 @@ func (p *Plot) DataCanvas(da draw.Canvas) draw.Canvas { x := horizontalAxis{p.X} p.Y.sanitizeRange() y := verticalAxis{p.Y} - return padY(p, padX(p, draw.Crop(da, y.size(), x.size(), 0, 0))) + return padY(p, padX(p, draw.Crop(da, y.size(), 0, x.size(), 0))) } // DrawGlyphBoxes draws red outlines around the plot's diff --git a/vendor/github.com/gonum/plot/plotter/barchart.go b/vendor/gonum.org/v1/plot/plotter/barchart.go similarity index 98% rename from vendor/github.com/gonum/plot/plotter/barchart.go rename to vendor/gonum.org/v1/plot/plotter/barchart.go index b0ba36e6..7cf37270 100644 --- a/vendor/github.com/gonum/plot/plotter/barchart.go +++ b/vendor/gonum.org/v1/plot/plotter/barchart.go @@ -9,9 +9,9 @@ import ( "image/color" "math" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // A BarChart presents grouped data with rectangular bars diff --git a/vendor/github.com/gonum/plot/plotter/boxplot.go b/vendor/gonum.org/v1/plot/plotter/boxplot.go similarity index 99% rename from vendor/github.com/gonum/plot/plotter/boxplot.go rename to vendor/gonum.org/v1/plot/plotter/boxplot.go index 76985d85..e3f3ec87 100644 --- a/vendor/github.com/gonum/plot/plotter/boxplot.go +++ b/vendor/gonum.org/v1/plot/plotter/boxplot.go @@ -9,9 +9,9 @@ import ( "math" "sort" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // fiveStatPlot contains the shared fields for quartile diff --git a/vendor/github.com/gonum/plot/plotter/colorbar.go b/vendor/gonum.org/v1/plot/plotter/colorbar.go similarity index 85% rename from vendor/github.com/gonum/plot/plotter/colorbar.go rename to vendor/gonum.org/v1/plot/plotter/colorbar.go index f1bab267..c2bac2b4 100644 --- a/vendor/github.com/gonum/plot/plotter/colorbar.go +++ b/vendor/gonum.org/v1/plot/plotter/colorbar.go @@ -7,10 +7,10 @@ package plotter import ( "image" - "github.com/gonum/plot" - "github.com/gonum/plot/palette" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/palette" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // ColorBar is a plot.Plotter that draws a color bar legend for a ColorMap. @@ -30,15 +30,15 @@ type ColorBar struct { // colors returns the number of colors to be shown // in the legend, substituting invalid values -// with the default of one color per vg.Point. +// with the default of one color per point. func (l *ColorBar) colors(c draw.Canvas) int { if l.Colors > 0 { return l.Colors } if l.Vertical { - return int((c.Max.Y - c.Min.Y).Points()) + return int(c.Max.Y - c.Min.Y) } - return int((c.Max.X - c.Min.X).Points()) + return int(c.Max.X - c.Min.X) } // check determines whether the ColorBar is @@ -58,18 +58,19 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) { colors := l.colors(c) var img *image.NRGBA64 var xmin, xmax, ymin, ymax vg.Length + delta := (l.ColorMap.Max() - l.ColorMap.Min()) / float64(colors) if l.Vertical { trX, trY := p.Transforms(&c) - xmin = trX(l.ColorMap.Min()) - ymin = trY(0) - xmax = trX(l.ColorMap.Max()) - ymax = trY(1) + xmin = trX(0) + ymin = trY(l.ColorMap.Min()) + xmax = trX(1) + ymax = trY(l.ColorMap.Max()) img = image.NewNRGBA64(image.Rectangle{ Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: 1, Y: colors}, }) for i := 0; i < colors; i++ { - color, err := l.ColorMap.At(float64(i) / float64(colors-1)) + color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i)) if err != nil { panic(err) } @@ -77,16 +78,16 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) { } } else { trX, trY := p.Transforms(&c) - ymin = trY(l.ColorMap.Min()) - xmin = trX(0) - ymax = trY(l.ColorMap.Max()) - xmax = trX(1) + xmin = trX(l.ColorMap.Min()) + ymin = trY(0) + xmax = trX(l.ColorMap.Max()) + ymax = trY(1) img = image.NewNRGBA64(image.Rectangle{ Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: colors, Y: 1}, }) for i := 0; i < colors; i++ { - color, err := l.ColorMap.At(float64(i) / float64(colors-1)) + color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i)) if err != nil { panic(err) } diff --git a/vendor/github.com/gonum/plot/plotter/conrec.go b/vendor/gonum.org/v1/plot/plotter/conrec.go similarity index 100% rename from vendor/github.com/gonum/plot/plotter/conrec.go rename to vendor/gonum.org/v1/plot/plotter/conrec.go diff --git a/vendor/github.com/gonum/plot/plotter/contour.go b/vendor/gonum.org/v1/plot/plotter/contour.go similarity index 98% rename from vendor/github.com/gonum/plot/plotter/contour.go rename to vendor/gonum.org/v1/plot/plotter/contour.go index d7d6c5c3..58fb9bd9 100644 --- a/vendor/github.com/gonum/plot/plotter/contour.go +++ b/vendor/gonum.org/v1/plot/plotter/contour.go @@ -9,10 +9,10 @@ import ( "math" "sort" - "github.com/gonum/plot" - "github.com/gonum/plot/palette" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/palette" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // Contour implements the Plotter interface, drawing @@ -50,6 +50,8 @@ type Contour struct { // the 0.01, 0.05, 0.25, 0.5, 0.75, 0.95 and 0.99 quantiles. // If g has Min and Max methods that return a float, those returned // values are used to set the respective Contour fields. +// If the returned Contour is used when Min is greater than Max, the +// Plot method will panic. func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour { var min, max float64 type minMaxer interface { @@ -122,6 +124,10 @@ const naive = false // Plot implements the Plot method of the plot.Plotter interface. func (h *Contour) Plot(c draw.Canvas, plt *plot.Plot) { + if h.Min > h.Max { + panic("contour: invalid Z range: min greater than max") + } + if naive { h.naivePlot(c, plt) return diff --git a/vendor/github.com/gonum/plot/plotter/errbars.go b/vendor/gonum.org/v1/plot/plotter/errbars.go similarity index 98% rename from vendor/github.com/gonum/plot/plotter/errbars.go rename to vendor/gonum.org/v1/plot/plotter/errbars.go index 23ba3905..eae71a70 100644 --- a/vendor/github.com/gonum/plot/plotter/errbars.go +++ b/vendor/gonum.org/v1/plot/plotter/errbars.go @@ -7,9 +7,9 @@ package plotter import ( "math" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // DefaultCapWidth is the default width of error bar caps. diff --git a/vendor/github.com/gonum/plot/plotter/functions.go b/vendor/gonum.org/v1/plot/plotter/functions.go similarity index 77% rename from vendor/github.com/gonum/plot/plotter/functions.go rename to vendor/gonum.org/v1/plot/plotter/functions.go index 9c52886c..3d022327 100644 --- a/vendor/github.com/gonum/plot/plotter/functions.go +++ b/vendor/gonum.org/v1/plot/plotter/functions.go @@ -5,16 +5,22 @@ package plotter import ( - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // Function implements the Plotter interface, // drawing a line for the given function. type Function struct { - F func(float64) float64 + F func(x float64) (y float64) + + // XMin and XMax specify the range + // of x values to pass to F. + XMin, XMax float64 + Samples int + draw.LineStyle } @@ -33,10 +39,15 @@ func NewFunction(f func(float64) float64) *Function { func (f *Function) Plot(c draw.Canvas, p *plot.Plot) { trX, trY := p.Transforms(&c) - d := (p.X.Max - p.X.Min) / float64(f.Samples-1) + min, max := f.XMin, f.XMax + if min == 0 && max == 0 { + min = p.X.Min + max = p.X.Max + } + d := (max - min) / float64(f.Samples-1) line := make([]vg.Point, f.Samples) for i := range line { - x := p.X.Min + float64(i)*d + x := min + float64(i)*d line[i].X = trX(x) line[i].Y = trY(f.F(x)) } diff --git a/vendor/github.com/gonum/plot/plotter/glyphbox.go b/vendor/gonum.org/v1/plot/plotter/glyphbox.go similarity index 91% rename from vendor/github.com/gonum/plot/plotter/glyphbox.go rename to vendor/gonum.org/v1/plot/plotter/glyphbox.go index 275460d8..6ca05fba 100644 --- a/vendor/github.com/gonum/plot/plotter/glyphbox.go +++ b/vendor/gonum.org/v1/plot/plotter/glyphbox.go @@ -7,9 +7,9 @@ package plotter import ( "image/color" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // GlyphBoxes implements the Plotter interface, drawing diff --git a/vendor/github.com/gonum/plot/plotter/grid.go b/vendor/gonum.org/v1/plot/plotter/grid.go similarity index 94% rename from vendor/github.com/gonum/plot/plotter/grid.go rename to vendor/gonum.org/v1/plot/plotter/grid.go index 55040686..55766639 100644 --- a/vendor/github.com/gonum/plot/plotter/grid.go +++ b/vendor/gonum.org/v1/plot/plotter/grid.go @@ -7,9 +7,9 @@ package plotter import ( "image/color" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) var ( diff --git a/vendor/github.com/gonum/plot/plotter/heat.go b/vendor/gonum.org/v1/plot/plotter/heat.go similarity index 88% rename from vendor/github.com/gonum/plot/plotter/heat.go rename to vendor/gonum.org/v1/plot/plotter/heat.go index d4a19237..4eeeb792 100644 --- a/vendor/github.com/gonum/plot/plotter/heat.go +++ b/vendor/gonum.org/v1/plot/plotter/heat.go @@ -8,10 +8,10 @@ import ( "image/color" "math" - "github.com/gonum/plot" - "github.com/gonum/plot/palette" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/palette" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // GridXYZ describes three dimensional data where the X and Y @@ -49,6 +49,11 @@ type HeatMap struct { Underflow color.Color Overflow color.Color + // NaN is the color used to fill heat map elements + // that are NaN or do not map to a unique palette + // color. + NaN color.Color + // Min and Max define the dynamic range of the // heat map. Min, Max float64 @@ -57,8 +62,8 @@ type HeatMap struct { // NewHeatMap creates as new heat map plotter for the given data, // using the provided palette. If g has Min and Max methods that return // a float, those returned values are used to set the respective HeatMap -// fields. If the returned HeatMap is used when Min is greater than or -// equal to Max, the Plot method will panic. +// fields. If the returned HeatMap is used when Min is greater than Max, +// the Plot method will panic. func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap { var min, max float64 type minMaxer interface { @@ -93,8 +98,8 @@ func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap { // Plot implements the Plot method of the plot.Plotter interface. func (h *HeatMap) Plot(c draw.Canvas, plt *plot.Plot) { - if h.Min >= h.Max { - panic("heatmap: non-positive Z range") + if h.Min > h.Max { + panic("contour: invalid Z range: min greater than max") } pal := h.Palette.Colors() if len(pal) == 0 { @@ -108,14 +113,13 @@ func (h *HeatMap) Plot(c draw.Canvas, plt *plot.Plot) { var pa vg.Path cols, rows := h.GridXYZ.Dims() for i := 0; i < cols; i++ { - var right, left float64 switch i { case 0: - right = (h.GridXYZ.X(i+1) - h.GridXYZ.X(i)) / 2 + right = (h.GridXYZ.X(1) - h.GridXYZ.X(0)) / 2 left = -right case cols - 1: - right = (h.GridXYZ.X(i) - h.GridXYZ.X(i-1)) / 2 + right = (h.GridXYZ.X(cols-1) - h.GridXYZ.X(cols-2)) / 2 left = -right default: right = (h.GridXYZ.X(i+1) - h.GridXYZ.X(i)) / 2 @@ -123,20 +127,13 @@ func (h *HeatMap) Plot(c draw.Canvas, plt *plot.Plot) { } for j := 0; j < rows; j++ { - v := h.GridXYZ.Z(i, j) - if math.IsNaN(v) || math.IsInf(v, 0) { - continue - } - - pa = pa[:0] - var up, down float64 switch j { case 0: - up = (h.GridXYZ.Y(j+1) - h.GridXYZ.Y(j)) / 2 + up = (h.GridXYZ.Y(1) - h.GridXYZ.Y(0)) / 2 down = -up case rows - 1: - up = (h.GridXYZ.Y(j) - h.GridXYZ.Y(j-1)) / 2 + up = (h.GridXYZ.Y(rows-1) - h.GridXYZ.Y(rows-2)) / 2 down = -up default: up = (h.GridXYZ.Y(j+1) - h.GridXYZ.Y(j)) / 2 @@ -150,6 +147,7 @@ func (h *HeatMap) Plot(c draw.Canvas, plt *plot.Plot) { continue } + pa = pa[:0] pa.Move(vg.Point{X: x, Y: y}) pa.Line(vg.Point{X: dx, Y: y}) pa.Line(vg.Point{X: dx, Y: dy}) @@ -157,11 +155,13 @@ func (h *HeatMap) Plot(c draw.Canvas, plt *plot.Plot) { pa.Close() var col color.Color - switch { + switch v := h.GridXYZ.Z(i, j); { case v < h.Min: col = h.Underflow case v > h.Max: col = h.Overflow + case math.IsNaN(v), math.IsInf(ps, 0): + col = h.NaN default: col = pal[int((v-h.Min)*ps+0.5)] // Apply palette scaling. } diff --git a/vendor/github.com/gonum/plot/plotter/histogram.go b/vendor/gonum.org/v1/plot/plotter/histogram.go similarity index 98% rename from vendor/github.com/gonum/plot/plotter/histogram.go rename to vendor/gonum.org/v1/plot/plotter/histogram.go index b8664af5..091f3cd8 100644 --- a/vendor/github.com/gonum/plot/plotter/histogram.go +++ b/vendor/gonum.org/v1/plot/plotter/histogram.go @@ -10,9 +10,9 @@ import ( "image/color" "math" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // Histogram implements the Plotter interface, diff --git a/vendor/github.com/gonum/plot/plotter/image.go b/vendor/gonum.org/v1/plot/plotter/image.go similarity index 95% rename from vendor/github.com/gonum/plot/plotter/image.go rename to vendor/gonum.org/v1/plot/plotter/image.go index ce26b6ec..19c5c265 100644 --- a/vendor/github.com/gonum/plot/plotter/image.go +++ b/vendor/gonum.org/v1/plot/plotter/image.go @@ -8,9 +8,9 @@ import ( "image" "math" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // Image is a plotter that draws a scaled, raster image. diff --git a/vendor/github.com/gonum/plot/plotter/johnson.go b/vendor/gonum.org/v1/plot/plotter/johnson.go similarity index 100% rename from vendor/github.com/gonum/plot/plotter/johnson.go rename to vendor/gonum.org/v1/plot/plotter/johnson.go diff --git a/vendor/github.com/gonum/plot/plotter/labels.go b/vendor/gonum.org/v1/plot/plotter/labels.go similarity index 96% rename from vendor/github.com/gonum/plot/plotter/labels.go rename to vendor/gonum.org/v1/plot/plotter/labels.go index 57c81d44..f08033f3 100644 --- a/vendor/github.com/gonum/plot/plotter/labels.go +++ b/vendor/gonum.org/v1/plot/plotter/labels.go @@ -7,9 +7,9 @@ package plotter import ( "errors" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) var ( diff --git a/vendor/github.com/gonum/plot/plotter/line.go b/vendor/gonum.org/v1/plot/plotter/line.go similarity index 96% rename from vendor/github.com/gonum/plot/plotter/line.go rename to vendor/gonum.org/v1/plot/plotter/line.go index 208af0ba..3b04d8a2 100644 --- a/vendor/github.com/gonum/plot/plotter/line.go +++ b/vendor/gonum.org/v1/plot/plotter/line.go @@ -7,9 +7,9 @@ package plotter import ( "image/color" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // Line implements the Plotter interface, drawing a line. diff --git a/vendor/github.com/gonum/plot/plotter/palettethumbnailer.go b/vendor/gonum.org/v1/plot/plotter/palettethumbnailer.go similarity index 89% rename from vendor/github.com/gonum/plot/plotter/palettethumbnailer.go rename to vendor/gonum.org/v1/plot/plotter/palettethumbnailer.go index 29441d16..67421a5a 100644 --- a/vendor/github.com/gonum/plot/plotter/palettethumbnailer.go +++ b/vendor/gonum.org/v1/plot/plotter/palettethumbnailer.go @@ -7,10 +7,10 @@ package plotter import ( "image/color" - "github.com/gonum/plot" - "github.com/gonum/plot/palette" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/palette" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // PaletteThumbnailers creates a slice of plot.Thumbnailers that can be used to diff --git a/vendor/github.com/gonum/plot/plotter/plotter.go b/vendor/gonum.org/v1/plot/plotter/plotter.go similarity index 87% rename from vendor/github.com/gonum/plot/plotter/plotter.go rename to vendor/gonum.org/v1/plot/plotter/plotter.go index 1b4fe904..826c1458 100644 --- a/vendor/github.com/gonum/plot/plotter/plotter.go +++ b/vendor/gonum.org/v1/plot/plotter/plotter.go @@ -2,27 +2,25 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -/* -Package plotter defines a variety of standard Plotters for the -plot package. - -Plotters use the primitives provided by the plot package to draw to -the data area of a plot. This package provides some standard data -styles such as lines, scatter plots, box plots, labels, and more. - -New* functions return an error if the data contains Inf, NaN, or is -empty. Some of the New* functions return other plotter-specific errors -too. -*/ -package plotter +// Package plotter defines a variety of standard Plotters for the +// plot package. +// +// Plotters use the primitives provided by the plot package to draw to +// the data area of a plot. This package provides some standard data +// styles such as lines, scatter plots, box plots, labels, and more. +// +// New* functions return an error if the data contains Inf, NaN, or is +// empty. Some of the New* functions return other plotter-specific errors +// too. +package plotter // import "gonum.org/v1/plot/plotter" import ( "errors" "image/color" "math" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) var ( @@ -183,6 +181,9 @@ type XYZer interface { // XYZ returns an x, y, z triple. XYZ(int) (float64, float64, float64) + + // XY returns an x, y pair. + XY(int) (float64, float64) } // XYZs implements the XYZer interface using a slice. @@ -198,6 +199,11 @@ func (xyz XYZs) XYZ(i int) (float64, float64, float64) { return xyz[i].X, xyz[i].Y, xyz[i].Z } +// XY implements the XY method of the XYer interface. +func (xyz XYZs) XY(i int) (float64, float64) { + return xyz[i].X, xyz[i].Y +} + // CopyXYZs copies an XYZer. func CopyXYZs(data XYZer) (XYZs, error) { cpy := make(XYZs, data.Len()) diff --git a/vendor/github.com/gonum/plot/plotter/polygon.go b/vendor/gonum.org/v1/plot/plotter/polygon.go similarity index 97% rename from vendor/github.com/gonum/plot/plotter/polygon.go rename to vendor/gonum.org/v1/plot/plotter/polygon.go index 070f107b..27900b40 100644 --- a/vendor/github.com/gonum/plot/plotter/polygon.go +++ b/vendor/gonum.org/v1/plot/plotter/polygon.go @@ -8,9 +8,9 @@ import ( "image/color" "math" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // Polygon implements the Plotter interface, drawing a polygon. diff --git a/vendor/github.com/gonum/plot/plotter/quartile.go b/vendor/gonum.org/v1/plot/plotter/quartile.go similarity index 98% rename from vendor/github.com/gonum/plot/plotter/quartile.go rename to vendor/gonum.org/v1/plot/plotter/quartile.go index 3d052a27..8f538ef9 100644 --- a/vendor/github.com/gonum/plot/plotter/quartile.go +++ b/vendor/gonum.org/v1/plot/plotter/quartile.go @@ -7,9 +7,9 @@ package plotter import ( "image/color" - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) var ( diff --git a/vendor/github.com/gonum/plot/plotter/sankey.go b/vendor/gonum.org/v1/plot/plotter/sankey.go similarity index 99% rename from vendor/github.com/gonum/plot/plotter/sankey.go rename to vendor/gonum.org/v1/plot/plotter/sankey.go index 656a206e..4a4fbba0 100644 --- a/vendor/github.com/gonum/plot/plotter/sankey.go +++ b/vendor/gonum.org/v1/plot/plotter/sankey.go @@ -10,10 +10,10 @@ import ( "math" "sort" - "github.com/gonum/plot" - "github.com/gonum/plot/tools/bezier" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/tools/bezier" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // A Sankey diagram presents stock and flow data as rectangles representing diff --git a/vendor/github.com/gonum/plot/plotter/scatter.go b/vendor/gonum.org/v1/plot/plotter/scatter.go similarity index 70% rename from vendor/github.com/gonum/plot/plotter/scatter.go rename to vendor/gonum.org/v1/plot/plotter/scatter.go index e613ce3a..875e5d2c 100644 --- a/vendor/github.com/gonum/plot/plotter/scatter.go +++ b/vendor/gonum.org/v1/plot/plotter/scatter.go @@ -5,9 +5,9 @@ package plotter import ( - "github.com/gonum/plot" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // Scatter implements the Plotter interface, drawing @@ -16,6 +16,10 @@ type Scatter struct { // XYs is a copy of the points for this scatter. XYs + // GlyphStyleFunc, if not nil, specifies GlyphStyles + // for individual points + GlyphStyleFunc func(int) draw.GlyphStyle + // GlyphStyle is the style of the glyphs drawn // at each point. draw.GlyphStyle @@ -38,8 +42,12 @@ func NewScatter(xys XYer) (*Scatter, error) { // interface. func (pts *Scatter) Plot(c draw.Canvas, plt *plot.Plot) { trX, trY := plt.Transforms(&c) - for _, p := range pts.XYs { - c.DrawGlyph(pts.GlyphStyle, vg.Point{X: trX(p.X), Y: trY(p.Y)}) + glyph := func(i int) draw.GlyphStyle { return pts.GlyphStyle } + if pts.GlyphStyleFunc != nil { + glyph = pts.GlyphStyleFunc + } + for i, p := range pts.XYs { + c.DrawGlyph(glyph(i), vg.Point{X: trX(p.X), Y: trY(p.Y)}) } } @@ -53,11 +61,19 @@ func (pts *Scatter) DataRange() (xmin, xmax, ymin, ymax float64) { // GlyphBoxes returns a slice of plot.GlyphBoxes, // implementing the plot.GlyphBoxer interface. func (pts *Scatter) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox { + glyph := func(i int) draw.GlyphStyle { return pts.GlyphStyle } + if pts.GlyphStyleFunc != nil { + glyph = pts.GlyphStyleFunc + } bs := make([]plot.GlyphBox, len(pts.XYs)) for i, p := range pts.XYs { bs[i].X = plt.X.Norm(p.X) bs[i].Y = plt.Y.Norm(p.Y) - bs[i].Rectangle = pts.GlyphStyle.Rectangle() + r := glyph(i).Radius + bs[i].Rectangle = vg.Rectangle{ + Min: vg.Point{X: -r, Y: -r}, + Max: vg.Point{X: +r, Y: +r}, + } } return bs } diff --git a/vendor/github.com/gonum/plot/plotter/volcano_example.go b/vendor/gonum.org/v1/plot/plotter/volcano_example.go similarity index 98% rename from vendor/github.com/gonum/plot/plotter/volcano_example.go rename to vendor/gonum.org/v1/plot/plotter/volcano_example.go index 85c5b87c..4057ac1f 100644 --- a/vendor/github.com/gonum/plot/plotter/volcano_example.go +++ b/vendor/gonum.org/v1/plot/plotter/volcano_example.go @@ -13,15 +13,15 @@ package main import ( "image/color" - "github.com/gonum/matrix/mat64" - "github.com/gonum/plot" - "github.com/gonum/plot/palette" - "github.com/gonum/plot/plotter" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/gonum/mat" + "gonum.org/v1/plot" + "gonum.org/v1/plot/palette" + "gonum.org/v1/plot/plotter" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) -type deciGrid struct{ mat64.Matrix } +type deciGrid struct{ mat.Matrix } func (g deciGrid) Dims() (c, r int) { r, c = g.Matrix.Dims(); return c, r } func (g deciGrid) Z(c, r int) float64 { return g.Matrix.At(r, c) } @@ -42,7 +42,7 @@ func (g deciGrid) Y(r int) float64 { func main() { var levels []float64 - for l := 100.5; l < volcano.Matrix.(*mat64.Dense).Max(); l += 5 { + for l := 100.5; l < volcano.Matrix.(*mat.Dense).Max(); l += 5 { levels = append(levels, l) } c := plotter.NewContour(volcano, levels, palette.Rainbow(len(levels), (palette.Yellow+palette.Red)/2, palette.Blue, 1, 1, 1)) @@ -90,7 +90,7 @@ func main() { } // Data extracted from RDatasets volcano data for the Maunga Whau volcano topographic data. -var volcano = deciGrid{mat64.NewDense(87, 61, []float64{ +var volcano = deciGrid{mat.NewDense(87, 61, []float64{ 100, 100, 101, 101, 101, 101, 101, 100, 100, 100, 101, 101, 102, 102, 102, 102, 103, 104, 103, 102, 101, 101, 102, 103, 104, 104, 105, 107, 107, 107, 108, 108, 110, 110, 110, 110, 110, 110, 110, 110, 108, 108, 108, 107, 107, 108, 108, 108, 108, 108, 107, 107, 107, 107, 106, 106, 105, 105, 104, 104, 103, 101, 101, 102, 102, 102, 102, 102, 101, 101, 101, 102, 102, 103, 103, 103, 103, 104, 105, 104, 103, 102, 102, 103, 105, 106, 106, 107, 109, 110, 110, 110, 110, 111, 112, 113, 114, 116, 115, 114, 112, 110, 110, 110, 109, 108, 109, 109, 109, 109, 108, 108, 108, 108, 107, 107, 106, 106, 105, 105, 104, 104, 102, 102, 103, 103, 103, 103, 103, 102, 102, 102, 103, 103, 104, 104, 104, 104, 105, 106, 105, 104, 104, 105, 106, 107, 108, 110, 111, 113, 114, 115, 114, 115, 116, 118, 119, 119, 121, 121, 120, 118, 116, 114, 112, 111, 110, 110, 110, 110, 109, 109, 109, 109, 108, 108, 107, 107, 106, 106, 105, 105, 104, diff --git a/vendor/github.com/gonum/plot/plotutil/add.go b/vendor/gonum.org/v1/plot/plotutil/add.go similarity index 99% rename from vendor/github.com/gonum/plot/plotutil/add.go rename to vendor/gonum.org/v1/plot/plotutil/add.go index bb5627e8..b1d0ecf0 100644 --- a/vendor/github.com/gonum/plot/plotutil/add.go +++ b/vendor/gonum.org/v1/plot/plotutil/add.go @@ -8,9 +8,9 @@ import ( "errors" "fmt" - "github.com/gonum/plot" - "github.com/gonum/plot/plotter" - "github.com/gonum/plot/vg" + "gonum.org/v1/plot" + "gonum.org/v1/plot/plotter" + "gonum.org/v1/plot/vg" ) type combineXYs struct{ xs, ys plotter.Valuer } diff --git a/vendor/github.com/gonum/plot/plotutil/errorpoints.go b/vendor/gonum.org/v1/plot/plotutil/errorpoints.go similarity index 98% rename from vendor/github.com/gonum/plot/plotutil/errorpoints.go rename to vendor/gonum.org/v1/plot/plotutil/errorpoints.go index 694ba593..bdb0a8bb 100644 --- a/vendor/github.com/gonum/plot/plotutil/errorpoints.go +++ b/vendor/gonum.org/v1/plot/plotutil/errorpoints.go @@ -8,7 +8,7 @@ import ( "math" "sort" - "github.com/gonum/plot/plotter" + "gonum.org/v1/plot/plotter" ) // ErrorPoints holds a set of x, y pairs along diff --git a/vendor/github.com/gonum/plot/plotutil/main.go b/vendor/gonum.org/v1/plot/plotutil/main.go similarity index 97% rename from vendor/github.com/gonum/plot/plotutil/main.go rename to vendor/gonum.org/v1/plot/plotutil/main.go index edde4b23..de845d87 100644 --- a/vendor/github.com/gonum/plot/plotutil/main.go +++ b/vendor/gonum.org/v1/plot/plotutil/main.go @@ -9,9 +9,9 @@ package main import ( "math/rand" - "github.com/gonum/plot" - "github.com/gonum/plot/plotter" - "github.com/gonum/plot/plotutil" + "gonum.org/v1/plot" + "gonum.org/v1/plot/plotter" + "gonum.org/v1/plot/plotutil" ) var examples = []struct { diff --git a/vendor/github.com/gonum/plot/plotutil/plotutil.go b/vendor/gonum.org/v1/plot/plotutil/plotutil.go similarity index 90% rename from vendor/github.com/gonum/plot/plotutil/plotutil.go rename to vendor/gonum.org/v1/plot/plotutil/plotutil.go index 4fa9da1f..d3eda7cb 100644 --- a/vendor/github.com/gonum/plot/plotutil/plotutil.go +++ b/vendor/gonum.org/v1/plot/plotutil/plotutil.go @@ -2,20 +2,16 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -/* -Package plotutil contains a small number of utilites for creating -plots. - - -This package is under active development so portions of it may change. -*/ -package plotutil +// Package plotutil contains a small number of utilites for creating plots. +// +// This package is under active development so portions of it may change. +package plotutil // import "gonum.org/v1/plot/plotutil" import ( "image/color" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/draw" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/draw" ) // DefaultColors is a set of colors used by the Color function. diff --git a/vendor/github.com/gonum/plot/tools/bezier/bezier.go b/vendor/gonum.org/v1/plot/tools/bezier/bezier.go similarity index 95% rename from vendor/github.com/gonum/plot/tools/bezier/bezier.go rename to vendor/gonum.org/v1/plot/tools/bezier/bezier.go index c927346f..bef29062 100644 --- a/vendor/github.com/gonum/plot/tools/bezier/bezier.go +++ b/vendor/gonum.org/v1/plot/tools/bezier/bezier.go @@ -3,9 +3,9 @@ // license that can be found in the LICENSE file. // Package bezier implements 2D Bézier curve calculation. -package bezier +package bezier // import "gonum.org/v1/plot/tools/bezier" -import "github.com/gonum/plot/vg" +import "gonum.org/v1/plot/vg" type point struct { Point, Control vg.Point diff --git a/vendor/github.com/gonum/plot/vg/draw/canvas.go b/vendor/gonum.org/v1/plot/vg/draw/canvas.go similarity index 99% rename from vendor/github.com/gonum/plot/vg/draw/canvas.go rename to vendor/gonum.org/v1/plot/vg/draw/canvas.go index 666aed32..452d9c68 100644 --- a/vendor/github.com/gonum/plot/vg/draw/canvas.go +++ b/vendor/gonum.org/v1/plot/vg/draw/canvas.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package draw +package draw // import "gonum.org/v1/plot/vg/draw" import ( "fmt" @@ -10,11 +10,11 @@ import ( "math" "strings" - "github.com/gonum/plot/vg" - "github.com/gonum/plot/vg/vgeps" - "github.com/gonum/plot/vg/vgimg" - "github.com/gonum/plot/vg/vgpdf" - "github.com/gonum/plot/vg/vgsvg" + "gonum.org/v1/plot/vg" + "gonum.org/v1/plot/vg/vgeps" + "gonum.org/v1/plot/vg/vgimg" + "gonum.org/v1/plot/vg/vgpdf" + "gonum.org/v1/plot/vg/vgsvg" ) // A Canvas is a vector graphics canvas along with diff --git a/vendor/github.com/gonum/plot/vg/font.go b/vendor/gonum.org/v1/plot/vg/font.go similarity index 99% rename from vendor/github.com/gonum/plot/vg/font.go rename to vendor/gonum.org/v1/plot/vg/font.go index 6c3edfd3..406cd57f 100644 --- a/vendor/github.com/gonum/plot/vg/font.go +++ b/vendor/gonum.org/v1/plot/vg/font.go @@ -16,11 +16,12 @@ import ( "path/filepath" "sync" + "gonum.org/v1/plot/vg/fonts" + "golang.org/x/image/math/fixed" "github.com/golang/freetype" "github.com/golang/freetype/truetype" - "github.com/gonum/plot/vg/fonts" ) var ( diff --git a/vendor/github.com/gonum/plot/vg/font_syscall.go b/vendor/gonum.org/v1/plot/vg/font_syscall.go similarity index 95% rename from vendor/github.com/gonum/plot/vg/font_syscall.go rename to vendor/gonum.org/v1/plot/vg/font_syscall.go index b99d2570..910a8b4e 100644 --- a/vendor/github.com/gonum/plot/vg/font_syscall.go +++ b/vendor/gonum.org/v1/plot/vg/font_syscall.go @@ -16,7 +16,7 @@ const ( // importString is the import string expected for // this package. It is used to find the font // directory included with the package source. - importString = "github.com/gonum/plot/vg" + importString = "gonum.org/v1/plot/vg" ) func init() { diff --git a/vendor/github.com/gonum/plot/vg/fonts/fonts.go b/vendor/gonum.org/v1/plot/vg/fonts/fonts.go similarity index 84% rename from vendor/github.com/gonum/plot/vg/fonts/fonts.go rename to vendor/gonum.org/v1/plot/vg/fonts/fonts.go index bae035e5..636a70af 100644 --- a/vendor/github.com/gonum/plot/vg/fonts/fonts.go +++ b/vendor/gonum.org/v1/plot/vg/fonts/fonts.go @@ -3,6 +3,6 @@ // license that can be found in the LICENSE file. // Package fonts provides the Liberation fonts from https://fedorahosted.org/liberation-fonts/ -package fonts +package fonts // import "gonum.org/v1/plot/vg/fonts" //go:generate go run mk-fonts.go diff --git a/vendor/github.com/gonum/plot/vg/fonts/liberation_fonts_generated.go b/vendor/gonum.org/v1/plot/vg/fonts/liberation_fonts_generated.go similarity index 100% rename from vendor/github.com/gonum/plot/vg/fonts/liberation_fonts_generated.go rename to vendor/gonum.org/v1/plot/vg/fonts/liberation_fonts_generated.go diff --git a/vendor/github.com/gonum/plot/vg/fonts/mk-fonts.go b/vendor/gonum.org/v1/plot/vg/fonts/mk-fonts.go similarity index 97% rename from vendor/github.com/gonum/plot/vg/fonts/mk-fonts.go rename to vendor/gonum.org/v1/plot/vg/fonts/mk-fonts.go index 330b75f1..0844c5d7 100644 --- a/vendor/github.com/gonum/plot/vg/fonts/mk-fonts.go +++ b/vendor/gonum.org/v1/plot/vg/fonts/mk-fonts.go @@ -20,7 +20,7 @@ import ( ) const ( - baseUrl = "https://fedorahosted.org/releases/l/i/liberation-fonts/" + baseUrl = "https://releases.pagure.org/liberation-fonts/" fontsName = "liberation-fonts-ttf-2.00.1" ) @@ -88,7 +88,7 @@ func main() { } func getFontsDir() string { - dir := "github.com/gonum/plot/vg" + dir := "gonum.org/v1/plot/vg" gopath := os.Getenv("GOPATH") if gopath == "" { log.Fatal("no GOPATH environment variable") diff --git a/vendor/github.com/gonum/plot/vg/geom.go b/vendor/gonum.org/v1/plot/vg/geom.go similarity index 100% rename from vendor/github.com/gonum/plot/vg/geom.go rename to vendor/gonum.org/v1/plot/vg/geom.go diff --git a/vendor/github.com/gonum/plot/vg/len.go b/vendor/gonum.org/v1/plot/vg/len.go similarity index 100% rename from vendor/github.com/gonum/plot/vg/len.go rename to vendor/gonum.org/v1/plot/vg/len.go diff --git a/vendor/github.com/gonum/plot/vg/vg.go b/vendor/gonum.org/v1/plot/vg/vg.go similarity index 99% rename from vendor/github.com/gonum/plot/vg/vg.go rename to vendor/gonum.org/v1/plot/vg/vg.go index 86b03e7a..9c68cb3c 100644 --- a/vendor/github.com/gonum/plot/vg/vg.go +++ b/vendor/gonum.org/v1/plot/vg/vg.go @@ -5,7 +5,7 @@ // Package vg defines an interface for drawing 2D vector graphics. // This package is designed with the hope that many different // vector graphics back-ends can conform to the interface. -package vg +package vg // import "gonum.org/v1/plot/vg" import ( "image" diff --git a/vendor/github.com/gonum/plot/vg/vgeps/vgeps.go b/vendor/gonum.org/v1/plot/vg/vgeps/vgeps.go similarity index 97% rename from vendor/github.com/gonum/plot/vg/vgeps/vgeps.go rename to vendor/gonum.org/v1/plot/vg/vgeps/vgeps.go index 2ab08521..5a52e8b6 100644 --- a/vendor/github.com/gonum/plot/vg/vgeps/vgeps.go +++ b/vendor/gonum.org/v1/plot/vg/vgeps/vgeps.go @@ -4,7 +4,7 @@ // Package vgeps implements the vg.Canvas interface using // encapsulated postscript. -package vgeps +package vgeps // import "gonum.org/v1/plot/vg/vgeps" import ( "bufio" @@ -16,7 +16,7 @@ import ( "math" "time" - "github.com/gonum/plot/vg" + "gonum.org/v1/plot/vg" ) // DPI is the nominal resolution of drawing in EPS. @@ -54,7 +54,7 @@ func NewTitle(w, h vg.Length, title string) *Canvas { buf: new(bytes.Buffer), } c.buf.WriteString("%%!PS-Adobe-3.0 EPSF-3.0\n") - c.buf.WriteString("%%Creator github.com/gonum/plot/vg/vgeps\n") + c.buf.WriteString("%%Creator gonum.org/v1/plot/vg/vgeps\n") c.buf.WriteString("%%Title: " + title + "\n") c.buf.WriteString(fmt.Sprintf("%%%%BoundingBox: 0 0 %.*g %.*g\n", pr, w.Dots(DPI), diff --git a/vendor/github.com/gonum/plot/vg/vgimg/vgimg.go b/vendor/gonum.org/v1/plot/vg/vgimg/vgimg.go similarity index 95% rename from vendor/github.com/gonum/plot/vg/vgimg/vgimg.go rename to vendor/gonum.org/v1/plot/vg/vgimg/vgimg.go index ce4c0d9d..b35bacba 100644 --- a/vendor/github.com/gonum/plot/vg/vgimg/vgimg.go +++ b/vendor/gonum.org/v1/plot/vg/vgimg/vgimg.go @@ -5,7 +5,7 @@ // Package vgimg implements the vg.Canvas interface using // draw2d (github.com/llgcode/draw2d) // as a backend to output raster images. -package vgimg +package vgimg // import "gonum.org/v1/plot/vg/vgimg" import ( "bufio" @@ -16,13 +16,14 @@ import ( "image/jpeg" "image/png" "io" + "sync" "golang.org/x/image/tiff" "github.com/llgcode/draw2d" "github.com/llgcode/draw2d/draw2dimg" - "github.com/gonum/plot/vg" + "gonum.org/v1/plot/vg" ) // Canvas implements the vg.Canvas interface, @@ -265,10 +266,12 @@ func (c *Canvas) FillString(font vg.Font, pt vg.Point, str string) { defer c.gc.Restore() data := draw2d.FontData{Name: font.Name()} - if !registeredFont[font.Name()] { + registeredFont.Lock() + if !registeredFont.m[font.Name()] { draw2d.RegisterFont(data, font.Font()) - registeredFont[font.Name()] = true + registeredFont.m[font.Name()] = true } + registeredFont.Unlock() c.gc.SetFontData(data) c.gc.SetFontSize(font.Size.Points()) c.gc.Translate(pt.X.Dots(c.DPI()), pt.Y.Dots(c.DPI())) @@ -297,11 +300,12 @@ func (c *Canvas) DrawImage(rect vg.Rectangle, img image.Image) { c.gc.Restore() } -var ( - // RegisteredFont contains the set of font names - // that have already been registered with draw2d. - registeredFont = map[string]bool{} -) +// registeredFont contains the set of font names +// that have already been registered with draw2d. +var registeredFont = struct { + sync.Mutex + m map[string]bool +}{m: map[string]bool{}} // WriterCounter implements the io.Writer interface, and counts // the total number of bytes written. diff --git a/vendor/github.com/gonum/plot/vg/vgpdf/vgpdf.go b/vendor/gonum.org/v1/plot/vg/vgpdf/vgpdf.go similarity index 98% rename from vendor/github.com/gonum/plot/vg/vgpdf/vgpdf.go rename to vendor/gonum.org/v1/plot/vg/vgpdf/vgpdf.go index c96e2a64..a5dbde18 100644 --- a/vendor/github.com/gonum/plot/vg/vgpdf/vgpdf.go +++ b/vendor/gonum.org/v1/plot/vg/vgpdf/vgpdf.go @@ -4,7 +4,7 @@ // Package vgpdf implements the vg.Canvas interface // using gopdf (bitbucket.org/zombiezen/gopdf/pdf). -package vgpdf +package vgpdf // import "gonum.org/v1/plot/vg/vgpdf" import ( "bufio" @@ -15,7 +15,8 @@ import ( "math" "bitbucket.org/zombiezen/gopdf/pdf" - "github.com/gonum/plot/vg" + + "gonum.org/v1/plot/vg" ) // DPI is the nominal resolution of drawing in PDF. diff --git a/vendor/github.com/gonum/plot/vg/vgsvg/vgsvg.go b/vendor/gonum.org/v1/plot/vg/vgsvg/vgsvg.go similarity index 99% rename from vendor/github.com/gonum/plot/vg/vgsvg/vgsvg.go rename to vendor/gonum.org/v1/plot/vg/vgsvg/vgsvg.go index 57f1ec94..818c9d89 100644 --- a/vendor/github.com/gonum/plot/vg/vgsvg/vgsvg.go +++ b/vendor/gonum.org/v1/plot/vg/vgsvg/vgsvg.go @@ -4,7 +4,7 @@ // Package vgsvg uses svgo (github.com/ajstarks/svgo) // as a backend for vg. -package vgsvg +package vgsvg // import "gonum.org/v1/plot/vg/vgsvg" import ( "bufio" @@ -18,7 +18,8 @@ import ( "math" svgo "github.com/ajstarks/svgo" - "github.com/gonum/plot/vg" + + "gonum.org/v1/plot/vg" ) // DPI is the resolution of drawing in SVG. This value was determined by