[Rd] Bug in stars function (PR#738)
tdye@lava.net
tdye@lava.net
Sun, 19 Nov 2000 08:57:14 +0100 (MET)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
--1465796871-645734172-974620647=:18687
Content-Type: TEXT/PLAIN; charset=US-ASCII
Hi all,
I've discovered and (hopefully) fixed a bug in the stars function I wrote
some time ago. A corrected function is attached.
Please let me know if you have any questions or comments.
Tom
Thomas S. Dye, Ph.D. http://www.tsdye.com
Home: 812A 19th Avenue, Honolulu, Hawaii 96816. (808) 739-1367 or 387-9352.
Work: International Archaeological Research Institute, Inc., 2081 Young St.,
Honolulu, Hawaii 96826. Voice (808) 946-2548; Fax 943-0716.
--1465796871-645734172-974620647=:18687
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="new-stars.r"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.BSI.4.10.10011182157270.18687@malasada.lava.net>
Content-Description: bug fix
Content-Disposition: attachment; filename="new-stars.r"
ZnVuY3Rpb24gKHgsIGZ1bGwgPSBUUlVFLCBzY2FsZSA9IFRSVUUsIHJhZGl1
cyA9IFRSVUUsIGxhYmVscyA9IGRpbW5hbWVzKHgpW1sxXV0sIA0KICAgICAg
ICAgICAgbG9jYXRpb25zID0gTlVMTCwgeGxpbWl0ID0gTlVMTCwgeWxpbWl0
ID0gTlVMTCwgbGVuID0gMSwgDQogICAgICAgICAgICBjb2xvcnMgPSBOVUxM
LCBrZXkubG9jID0gTlVMTCwga2V5LmxhYmVscyA9IE5VTEwsIGRyYXcuc2Vn
bWVudHMgPSBGQUxTRSwgDQogICAgICAgICAgICBkcmF3LmF4ZXMgPSBGQUxT
RSwgLi4uKSANCnsNCiAgaWYgKGlzLmRhdGEuZnJhbWUoeCkpIA0KICAgIHgg
PC0gYXMubWF0cml4KHgpDQogIGVsc2UgaWYgKCFpcy5tYXRyaXgoeCkpIA0K
ICAgIHN0b3AoInggbXVzdCBiZSBh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0gIiIsIHlsYWIgPSAiIiwgYXNwID0gMSwg
YXhlcyA9IGRyYXcuYXhlcykNCiAgaWYgKGRyYXcuc2VnbWVudHMpIHsNCiAg
ICBmb3IgKGkgaW4gMTpuLmxvYykgew0KICAgICAgcG9seS54IDwtIE5BDQog
ICAgICBwb2x5LnkgPC0gTkENCiAgICAgIHN0YXJ0LnguY29vcmQgPC0geFtp
LCBdICogY29zKGFuZ2xlcykgKyBsb2NbaSwgMV0NCiAgICAgIHN0YXJ0Lnku
Y29vcmQgPC0geFtpLCBdICogc2luKGFuZ2xlcykgKyBsb2NbaSwgMl0NCiAg
ICAgIGZvciAoaiBpbiAxOm4uc2VnKSB7DQogICAgICAgIHBvbHkueCA8LSBj
KHBvbHkueCwgbG9jW2ksIDFdLCBzdGFydC54LmNvb3JkW2pdKQ0KICAgICAg
ICBwb2x5LnkgPC0gYyhwb2x5LnksIGxvY1tpLCAyXSwgc3RhcnQueS5jb29y
ZFtqXSkNCiAgICAgICAgbmV4dC5hbmdsZSA8LSBpZiAoaiA8IG4uc2VnKSAN
CiAgICAgICAgICBhbmdsZXNbaiArIDFdDQogICAgICAgIGVsc2UgKGlmIChm
dWxsKSANCiAgICAgICAgICAgICAgMzYwDQogICAgICAgIGVsc2UgMTgwKSAq
IGRlZw0KICAgICAgICBrIDwtIHNlcShmcm9tID0gYW5nbGVzW2pdLCB0byA9
IG5leHQuYW5nbGUsIGJ5ID0gZGVnKQ0KICAgICAgICBwb2x5LnggPC0gYyhw
b2x5LngsIHhbaSwgal0gKiBjb3MoaykgKyBsb2NbaSwgDQogICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAxXSwg
TkEpDQogICAgICAgIHBvbHkueSA8LSBjKHBvbHkueSwgeFtpLCBqXSAqIHNp
bihrKSArIGxvY1tpLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgIDJdLCBOQSkNCiAgICAgIH0NCiAgICAg
IHBhcihsd2QgPSAwLjI1KQ0KICAgICAgcG9seWdvbihwb2x5LngsIHBvbHku
eSwgY29sID0gc2VnLmNvbG9ycykNCiAgICAgIHBhcihsd2QgPSAxKQ0KICAg
ICAgaWYgKCFpcy5udWxsKGxhYmVscykpIA0KICAgICAgICB0ZXh0KGxvY1tp
LCAxXSwgbG9jW2ksIDJdIC0gaWYgKGZ1bGwpIA0KICAgICAgICAgICAgIG1h
eCh4KQ0KICAgICAgICBlbHNlIDAuMSAqIG1heCh4KSwgbGFiZWxzW2ldLCBj
ZXggPSAwLjUsIGFkaiA9IGMoMC41LCANCiAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDEpKQ0KICAgIH0NCiAg
fQ0KICBlbHNlIHsNCiAgICBmb3IgKGkgaW4gMTpuLmxvYykgew0KICAgICAg
dGVtcC54LmNvb3JkIDwtIHhbaSwgXSAqIGNvcyhhbmdsZXMpICsgbG9jW2ks
IDFdDQogICAgICB0ZW1wLnkuY29vcmQgPC0geFtpLCBdICogc2luKGFuZ2xl
cykgKyBsb2NbaSwgMl0NCiAgICAgIGlmIChyYWRpdXMpIHsNCiAgICAgICAg
cGFyKGx3ZCA9IDAuMjUpDQogICAgICAgIHNlZ21lbnRzKHJlcChsb2NbaSwg
MV0sIG4uc2VnKSwgcmVwKGxvY1tpLCAyXSwgDQogICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgIG4uc2VnKSwgdGVtcC54LmNv
b3JkLCB0ZW1wLnkuY29vcmQpDQogICAgICAgIHBhcihsd2QgPSAxKQ0KICAg
ICAgfQ0KICAgICAgbGluZXMoYyh0ZW1wLnguY29vcmQsIHRlbXAueC5jb29y
ZFsxXSksIGModGVtcC55LmNvb3JkLCANCiAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAueS5jb29yZFsxXSks
IGx3ZCA9IDAuMjUpDQogICAgICBpZiAoIWlzLm51bGwobGFiZWxzKSkgDQog
ICAgICAgIHRleHQobG9jW2ksIDFdLCBsb2NbaSwgMl0gLSBpZiAoZnVsbCkg
DQogICAgICAgICAgICAgbWF4KHgpDQogICAgICAgIGVsc2UgMC4xICogbWF4
KHgpLCBsYWJlbHNbaV0sIGNleCA9IDAuNSwgYWRqID0gYygwLjUsIA0KICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgMSkpDQogICAgfQ0KICB9DQogIGlmICghaXMubnVsbChrZXkubG9jKSkg
ew0KICAgIGlmIChkcmF3LnNlZ21lbnRzKSB7DQogICAgICBrZXkueCA8LSBO
QQ0KICAgICAga2V5LnkgPC0gTkENCiAgICAgIGtleS54LmNvb3JkIDwtIGNv
cyhhbmdsZXMpICogbGVuICsga2V5LmxvY1sxXQ0KICAgICAga2V5LnkuY29v
cmQgPC0gc2luKGFuZ2xlcykgKiBsZW4gKyBrZXkubG9jWzJdDQogICAgICBm
b3IgKGogaW4gMTpuLnNlZykgew0KICAgICAgICBrZXkueCA8LSBjKGtleS54
LCBrZXkubG9jWzFdLCBrZXkueC5jb29yZFtqXSkNCiAgICAgICAga2V5Lnkg
PC0gYyhrZXkueSwga2V5LmxvY1syXSwga2V5LnkuY29vcmRbal0pDQogICAg
ICAgIGsgPC0gYW5nbGVzW2pdICsgZGVnDQogICAgICAgIG5leHQuYW5nbGUg
PC0gaWYgKGogPCBuLnNlZykgDQogICAgICAgICAgYW5nbGVzW2ogKyAxXQ0K
ICAgICAgICBlbHNlIChpZiAoZnVsbCkgDQogICAgICAgICAgICAgIDM2MA0K
ICAgICAgICBlbHNlIDE4MCkgKiBkZWcNCiAgICAgICAgd2hpbGUgKGsgPCBu
ZXh0LmFuZ2xlKSB7DQogICAgICAgICAga2V5LnggPC0gYyhrZXkueCwgbGVu
ICogY29zKGspICsga2V5LmxvY1sxXSkNCiAgICAgICAgICBrZXkueSA8LSBj
KGtleS55LCBsZW4gKiBzaW4oaykgKyBrZXkubG9jWzJdKQ0KICAgICAgICAg
IGsgPC0gayArIGRlZw0KICAgICAgICB9DQogICAgICAgIGtleS54IDwtIGMo
a2V5LngsIGxlbiAqIGNvcyhuZXh0LmFuZ2xlKSArIGtleS5sb2NbMV0sIA0K
ICAgICAgICAgICAgICAgICAgIE5BKQ0KICAgICAgICBrZXkueSA8LSBjKGtl
eS55LCBsZW4gKiBzaW4obmV4dC5hbmdsZSkgKyBrZXkubG9jWzJdLCANCiAg
ICAgICAgICAgICAgICAgICBOQSkNCiAgICAgIH0NCiAgICAgIHBhcihsd2Qg
PSAwLjI1KQ0KICAgICAgcG9seWdvbihrZXkueCwga2V5LnksIGNvbCA9IHNl
Zy5jb2xvcnMpDQogICAgICBwYXIobHdkID0gMSkNCiAgICB9DQogICAgZWxz
ZSB7DQogICAgICB0ZW1wLnguY29vcmQgPC0gY29zKGFuZ2xlcykgKiBsZW4g
KyBrZXkubG9jWzFdDQogICAgICB0ZW1wLnkuY29vcmQgPC0gc2luKGFuZ2xl
cykgKiBsZW4gKyBrZXkubG9jWzJdDQogICAgICBwYXIobHdkID0gMC4yNSkN
CiAgICAgIGlmIChyYWRpdXMpIA0KICAgICAgICBzZWdtZW50cyhyZXAoa2V5
LmxvY1sxXSwgbi5zZWcpLCByZXAoa2V5LmxvY1syXSwgDQogICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuLnNlZyksIHRl
bXAueC5jb29yZCwgdGVtcC55LmNvb3JkKQ0KICAgICAgbGluZXMoYyh0ZW1w
LnguY29vcmQsIHRlbXAueC5jb29yZFsxXSksIGModGVtcC55LmNvb3JkLCAN
CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgIHRlbXAueS5jb29yZFsxXSkpDQogICAgICBwYXIobHdkID0gMSkNCiAg
ICB9DQogICAgaWYgKGlzLm51bGwoa2V5LmxhYmVscykpIA0KICAgICAga2V5
LmxhYmVscyA8LS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ICAgICAgICAgICAgICAgICAg
IGRlZykpLygxODAgKiBkZWcpKQ0KICAgICAgZWxzZSBpZiAobGFiLmFuZ2xb
a10gPiAoMjcwICogZGVnKSkgDQogICAgICAgIHRleHQuYWRqIDwtIGModGV4
dC5hZGosIDEgLSAoMC41ICogKGxhYi5hbmdsW2tdIC0gDQogICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgyNzAgKiBkZWcp
KS8oOTAgKiBkZWcpKSkNCiAgICAgIHRleHQuZGVmYXVsdCh4ID0gbGFiZWwu
eC5jb29yZFtrXSwgeSA9IGxhYmVsLnkuY29vcmRba10sIA0KICAgICAgICAg
ICAgICAgICAgIGxhYmVscyA9IGtleS5sYWJlbHNba10sIGNleCA9IDAuNSwg
YWRqID0gdGV4dC5hZGopDQogICAgfQ0KICB9DQogIGludmlzaWJsZSgpDQp9
DQo=
--1465796871-645734172-974620647=:18687--
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._