Deutsch   English   Français   Italiano  
<65ee04df$0$2572$426a74cc@news.free.fr>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.hispagatos.org!.POSTED!not-for-mail
From: rek2 hispagatos <rek2@hispagatos.org.invalid>
Newsgroups: comp.lang.go
Subject: Re: gonum panic
Date: Tue, 19 Mar 2024 02:40:28 -0000 (UTC)
Organization: Hispagatos
Message-ID: <utatus$2me53$1@matrix.hispagatos.org>
References: <f0lhvi9rp0ou7hsf2k80fs38hak379jgtg@4ax.com>
Reply-To: ReK2 <rek2@hispagatos.org>
Injection-Date: Tue, 19 Mar 2024 02:40:28 -0000 (UTC)
Injection-Info: matrix.hispagatos.org;
	logging-data="2832547"; mail-complaints-to="abuse@hispagatos.org"
User-Agent: slrn/pre1.0.4-9 (Linux)
Bytes: 1859
Lines: 41

On 2024-03-18, Rob <usenet@drrob1.com> wrote:
>
> // this function call panics w/ invalid memory reference or nil 
> // pointer dereference.
> 	err := qr.SolveTo(qrSoln, false, &B) 
> 	if err != nil {
> 		ctfmt.Printf(ct.Red, false, " Error from qr Solve To
> is %s.  Bye-Bye\n", err)
> 		os.Exit(1)
> 	}
> 	fmt.Printf(" Soluton by gonum QR factorization is:\n %v\n\n",
> gomat.Formatted(qrSoln))
>
> } // end gonumQRTest
>

I just overead very fast so double check this, 

var qrSoln gomat.Dense // Change this line, remove pointer.

// Initialize qrSoln
  qrSoln = *gomat.NewDense(0, 0, nil) // Initialize qrSoln with an empty dense matrix

....
err := qr.SolveTo(&qrSoln, false, &B) // Pass the address of qrSoln

The qrSoln pointer is not initialized, so it's pointing to nil, causing a panic 
when you try to dereference it.
https://pkg.go.dev/github.com/changkun/gomat#NewDense



Hope it helps.

Happy Hacking
ReK2


-- 
- {gemini,https}://{,rek2.}hispagatos.org - mastodon: @rek2@hispagatos.space
- [https|gemini]://2600.Madrid            - https://hispagatos.space/@rek2
- https://keyoxide.org/A31C7CE19D9C58084EA42BA26C0B0D11E9303EC5