#!/usr/bin/env bash

# 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.

echo Generating zdotu.go
echo -e '// Generated code do not edit. Run `go generate`.\n' > zdotu.go
cat ddot.go \
| grep -v '//+build' \
| gofmt -r 'float64 -> complex128' \
| sed 's/Ddot/Zdotu/' \
>> zdotu.go

echo Generating zdotc.go
echo -e '// Generated code do not edit. Run `go generate`.\n' > zdotc.go
cat ddot.go \
| grep -v '//+build' \
| gofmt -r 'float64 -> complex128' \
| gofmt -r 'y[i] * v -> y[i] * cmplx.Conj(v)' \
| sed 's/Ddot/Zdotc/' \
| goimports \
>> zdotc.go

echo Generating zaxpy.go
echo -e '// Generated code do not edit. Run `go generate`.\n' > zaxpy.go
cat daxpy.go \
| grep -v '//+build' \
| gofmt -r 'float64 -> complex128' \
| sed 's/Daxpy/Zaxpy/' \
>> zaxpy.go

echo Generating cdotu.go
echo -e '// Generated code do not edit. Run `go generate`.\n' > cdotu.go
cat ddot.go \
| grep -v '//+build' \
| gofmt -r 'float64 -> complex64' \
| sed 's/Ddot/Cdotu/' \
>> cdotu.go

echo Generating cdotc.go
echo -e '// Generated code do not edit. Run `go generate`.\n' > cdotc.go
cat ddot.go \
| grep -v '//+build' \
| gofmt -r 'float64 -> complex64' \
| gofmt -r 'y[i] * v -> y[i] * conj(v)' \
| sed 's/Ddot/Cdotc/' \
| goimports \
>> cdotc.go

echo Generating caxpy.go
echo -e '// Generated code do not edit. Run `go generate`.\n' > caxpy.go
cat daxpy.go \
| grep -v '//+build' \
| gofmt -r 'float64 -> complex64' \
| sed 's/Daxpy/Caxpy/' \
>> caxpy.go

