Dear all,
the following example crashes using latest git on ubuntu 18.10 with an
error:
<Speicherzugriffsfehler (Speicherabzug geschrieben)> aka 'memory access
violation'
<hansl>
clear
set verbose off
function bundle default_naiveFC_opts (const series y)
# Set default values
bundle self = null
self.h = 10 # forecast horizon
return self
end function
function bundle naiveFC (const series y,
string which "Select method",
bundle opts[null])
# Set up the bundle
bundle self = default_naiveFC_opts(y)
if exists(opts)
# override defaults
self = opts + self
endif
series self.y = y
# call method
if which=="meanf"
self.fc = meanf(&self) # !!! fails with a crash !!!
#self.fc = meanf2(&self) # works
endif
return self
end function
function matrix meanf2 (bundle *self)
return ones(self.h, 1) .* mean(self.y)
end function
function void meanf (bundle *self)
self.fc = ones(self.h, 1) .* mean(self.y)
eval self.fc
end function
# Example
open nysewk.gdt -q
bundle b = naiveFC(close, "meanf")
</hansl>
Interestingly, when you replace calling meanf() by meanf2() it works,
however.
Best,
Artur