1 // Copyright ©2015 The Gonum Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 // This file implements types for helping to convert to Fortran testing capabilities.
14 // fortran64 is a float64 type that prints as a double precision constant in
16 type fortran64 float64
18 func (f fortran64) String() string {
19 // Replace exponent with D
20 s := fmt.Sprintf("%0.16E", f)
21 s = strings.Replace(s, "E", "D", 1)
25 // printFortranArray prints a Go slice as an array that can be copied into a
27 func printFortranArray(z []float64, name string) {
28 fmt.Printf("%s(1:%d) = (/%v, &\n", name, len(z), fortran64(z[0]))
29 for i := 1; i < len(z)-1; i++ {
30 fmt.Printf("%v, &\n", fortran64(z[i]))
32 fmt.Printf("%s/)\n", fortran64(z[len(z)-1]))