[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Create matrix with random numbers

Jason Bornhoft

10/19/2007 9:30:00 PM

I would like to start evaluating Ruby's capabilities in processing large
linear systems and matrices and I would like to know if there is a
simple way to 'randomly' populate various matrices regardless of size or
type.

Any help, comments, anything is greatly appreciated!
--
Posted via http://www.ruby-....

30 Answers

Todd Benson

10/19/2007 9:48:00 PM

0

On 10/19/07, Jason Bornhoft <jbornhoft@gmail.com> wrote:
> I would like to start evaluating Ruby's capabilities in processing large
> linear systems and matrices and I would like to know if there is a
> simple way to 'randomly' populate various matrices regardless of size or
> type.
>
> Any help, comments, anything is greatly appreciated!

Not sure what you want exactly, but, maybe...

require 'matrix'
a, b = 2, 3
m = Matrix[*(Array.new(a) {Array.new(b) {rand}})]

Todd

Jason Bornhoft

10/20/2007 1:38:00 AM

0

> Not sure what you want exactly, but, maybe...
>
> require 'matrix'
> a, b = 2, 3
> m = Matrix[*(Array.new(a) {Array.new(b) {rand}})]
>
> Todd

What I would ideally like is to be able to specify the size of the
matrix and then have a random function populate the matrix with real
integers or, eventually, complex numbers.

Thanks for the guidance...
--
Posted via http://www.ruby-....

Rob Biedenharn

10/20/2007 4:56:00 AM

0

On Oct 19, 2007, at 9:38 PM, Jason Bornhoft wrote:
>> Not sure what you want exactly, but, maybe...
>>
>> require 'matrix'
>> a, b = 2, 3
>> m = Matrix[*(Array.new(a) {Array.new(b) {rand}})]
>>
>> Todd
>
> What I would ideally like is to be able to specify the size of the
> matrix and then have a random function populate the matrix with real
> integers or, eventually, complex numbers.
>
> Thanks for the guidance...

So something like:

require 'matrix'
def some_random_function
# make something up, perhaps something complex
end
rows, columns = 2, 3
matrix = Matrix[*(Array.new(rows) {Array.new(columns)
{ some_random_function }})]

And, yes, that just about exactly what you were already given. ;-)

-Rob

Rob Biedenharn http://agileconsult...
Rob@AgileConsultingLLC.com



Anim8rFSK

7/27/2013 1:51:00 AM

0

In article <k0r5v8li2mg7s2egofcpg08n2s9611ib3m@4ax.com>,
Mason Barge <masonbarge@gmail.com> wrote:

> On Fri, 26 Jul 2013 12:26:04 -0700, "BTR1701"
> <a54b123@webnntp.invalid> wrote:
>
> >On Jul 26 2013 8:18 AM, Adam H. Kerman wrote:
> >
> >> BTR1701 <atropos@mac.com> wrote:
> >> >"Adam H. Kerman" <ahk@chinet.com> wrote:
> >> >>BTR1701 <atropos@mac.com> wrote:
> >> >>>"Barb May" <barbmay@nonofyourbusinessx.tv> wrote:
> >> >>>>Mason Barge wrote:
> >>
> >> >>>>>So, maybe a few black leaders will say, "you know what, if we worried
> >> >>>>>more about what these black criminals are doing to our black
> >> >>>>>community
> >> >>>>>and stop trying to blame white people, we might actually improve
> >> >>>>>things."
> >>
> >> >>>>Sure, let's all stop blaming white people for the mass incarceration
> >> >>>>of
> >> >>>>blacks. After all, It's really their own fault because they are
> >> >>>>morally
> >> >>>>weak and because of black leaders who promote a sense of victimhood
> >> >>>>within the black community.
> >>
> >> >>>Then it's amazing that they can't seem to obey the same laws as
> >> >>>everyone
> >> >>>else. I mean, we're told these drug laws are racist, but I've managed
> >> >>>to
> >> >>>go my whole life without ever smoking marijuana, snorting coke, or
> >> >>>smoking crack. How is it my fault if someone else can't manage to do
> >> >>>the
> >> >>>same?
> >>
> >> >>Tell us how you grew up a poor black boy in the ghetto
> >>
> >> >There are plenty of poor black boys in the ghetto who manage to not be
> >> >criminals also.
> >>
> >> Yeah. They had decent parents and didn't live in circumstances that were
> >> so dire that they turned to drugs to escape. Tell us how many there are
> >> who didn't.
> >
> >Ah, so what you're saying is that they chose to commit crime. For every
> >one you show me that turned to crime to "escape" their bad life, I can
> >show you many who didn't.
> >
> >> Out of curiousity, shouldn't drug use be considered a victimless crime?
> >
> >I think so. Until it is, however, I obey the law.
>
> Oh, bullshit. As long as my tax dollars are paying for their medical
> care, all of their illegitimate spawn, buying them cell phones,
> subsidizing their rent, blah blah blah, I am a victim of their drug
> addiction.
>
> Plus, even if drugs were legal, do you think there wouldn't be people
> burglarizing houses for money to buy drugs?
>
> You ever see a baby born to an addict mother? There's another victim
> right there.

I'm also from the 'there will be carnage on the road' school as well,
since I know too many people that insist weed and coke don't impair
their driving at all, and only don't use and drive because they don't
want to get caught.

--
Wait - are you saying that ClodReamer was wrong, or lying?

Anim8rFSK

7/27/2013 1:53:00 AM

0

In article <69abcaxcpv.ln2@news.ezprovider.com>,
"BTR1701" <a54b123@webnntp.invalid> wrote:

> On Jul 26 2013 2:42 PM, Mason Barge wrote:
>
> > On Fri, 26 Jul 2013 12:26:04 -0700, "BTR1701"
> > <a54b123@webnntp.invalid> wrote:
> >
> > >On Jul 26 2013 8:18 AM, Adam H. Kerman wrote:
> > >
> > >> BTR1701 <atropos@mac.com> wrote:
> > >> >"Adam H. Kerman" <ahk@chinet.com> wrote:
> > >> >>BTR1701 <atropos@mac.com> wrote:
> > >> >>>"Barb May" <barbmay@nonofyourbusinessx.tv> wrote:
> > >> >>>>Mason Barge wrote:
> > >>
> > >> >>>>>So, maybe a few black leaders will say, "you know what, if we
> > >> >>>>>worried
> > >> >>>>>more about what these black criminals are doing to our black
> community
> > >> >>>>>and stop trying to blame white people, we might actually improve
> > >> >>>>>things."
> > >>
> > >> >>>>Sure, let's all stop blaming white people for the mass incarceration
> of
> > >> >>>>blacks. After all, It's really their own fault because they are
> morally
> > >> >>>>weak and because of black leaders who promote a sense of victimhood
> > >> >>>>within the black community.
> > >>
> > >> >>>Then it's amazing that they can't seem to obey the same laws as
> everyone
> > >> >>>else. I mean, we're told these drug laws are racist, but I've managed
> to
> > >> >>>go my whole life without ever smoking marijuana, snorting coke, or
> > >> >>>smoking crack. How is it my fault if someone else can't manage to do
> the
> > >> >>>same?
> > >>
> > >> >>Tell us how you grew up a poor black boy in the ghetto
> > >>
> > >> >There are plenty of poor black boys in the ghetto who manage to not be
> > >> >criminals also.
> > >>
> > >> Yeah. They had decent parents and didn't live in circumstances that were
> > >> so dire that they turned to drugs to escape. Tell us how many there are
> > >> who didn't.
> > >
> > >Ah, so what you're saying is that they chose to commit crime. For every
> > >one you show me that turned to crime to "escape" their bad life, I can
> > >show you many who didn't.
> > >
> > >> Out of curiousity, shouldn't drug use be considered a victimless crime?
> > >
> > >I think so. Until it is, however, I obey the law.
> >
> > Oh, bullshit. As long as my tax dollars are paying for their medical
> > care, all of their illegitimate spawn, buying them cell phones,
> > subsidizing their rent, blah blah blah, I am a victim of their drug
> > addiction.
> >
> > Plus, even if drugs were legal, do you think there wouldn't be people
> > burglarizing houses for money to buy drugs?
> >
> > You ever see a baby born to an addict mother? There's another victim
> > right there.
>
> The make all drugs illegal. Nicotine, caffeine, the whole bunch.
>
> But this idiocy where we allow people to legally smoke cigs and booze it
> up and become just addicted and dangerous to society on the one hand, but
> lock people up for smoking some weed on the other, is schizophrenic and
> illogical and frankly I'm sick of paying a shit-ton of taxes for the $10
> billion/year marijuana interdiction effort which has done fuck-all to stop
> people from buying, selling, and using marijuana.

While I agree with you in principle, I don't buy the 'this drug is legal
so we should make them all legal' school of thought.

--
Wait - are you saying that ClodReamer was wrong, or lying?

Thanatos

7/27/2013 2:32:00 AM

0

In article <ksv02u$osk$3@news.albasani.net>,
"Adam H. Kerman" <ahk@chinet.com> wrote:

> BTR1701 <a54b123@webnntp.invalid> wrote:
> >On Jul 26 2013 1:41 PM, Adam H. Kerman wrote:
> >
> >> BTR1701 <a54b123@webnntp.invalid> wrote:
> >> >On Jul 26 2013 8:18 AM, Adam H. Kerman wrote:
> >> >>BTR1701 <atropos@mac.com> wrote:
> >> >>>"Adam H. Kerman" <ahk@chinet.com> wrote:
> >> >>>>BTR1701 <atropos@mac.com> wrote:
> >> >>>>>"Barb May" <barbmay@nonofyourbusinessx.tv> wrote:
> >> >>>>>>Mason Barge wrote:
> >>
> >> >>>>>>>So, maybe a few black leaders will say, "you know what, if we
> >> >>>>>>>worried
> >> >>>>>>>more about what these black criminals are doing to our black
> >> >>>>>>>community
> >> >>>>>>>and stop trying to blame white people, we might actually improve
> >> >>>>>>>things."
> >>
> >> >>>>>>Sure, let's all stop blaming white people for the mass incarceration
> >of
> >> >>>>>>blacks. After all, It's really their own fault because they are
> >morally
> >> >>>>>>weak and because of black leaders who promote a sense of victimhood
> >> >>>>>>within the black community.
> >>
> >> >>>>>Then it's amazing that they can't seem to obey the same laws as
> >everyone
> >> >>>>>else. I mean, we're told these drug laws are racist, but I've managed
> >to
> >> >>>>>go my whole life without ever smoking marijuana, snorting coke, or
> >> >>>>>smoking crack. How is it my fault if someone else can't manage to do
> >the
> >> >>>>>same?
> >>
> >> >>>>Tell us how you grew up a poor black boy in the ghetto
> >>
> >> >>>There are plenty of poor black boys in the ghetto who manage to not be
> >> >>>criminals also.
> >>
> >> >>Yeah. They had decent parents and didn't live in circumstances that were
> >> >>so dire that they turned to drugs to escape. Tell us how many there are
> >> >>who didn't.
> >>
> >> >Ah, so what you're saying is that they chose to commit crime. For every
> >> >one you show me that turned to crime to "escape" their bad life, I can
> >> >show you many who didn't.
> >>
> >> Of course drug use is a choice. It doesn't make your childhood comparable
> >> to growing up a poor black child in the ghetto.
> >>
> >> In the ghetto
> >>
> >> >>Out of curiousity, shouldn't drug use be considered a victimless crime?
> >>
> >> >I think so. Until it is, however, I obey the law.
> >>
> >> Oh, golly. Some drugs are legal, like tobacco and alchohol. Don't you have
> >> the willpower to decide for yourself to use them, or do you lack this
> >> willpower and require the gubmint to take away your choice?
> >
> >Of course I do and I said as much.
>
> You're quoted above saying you don't take illegal drugs because they're
> illegal. I wanted to know if the choices you make with regard to drugs that
> aren't illegal, like tobacco and alchohol, are due to law or willpower.

Ah. Yes, I suppose if they made alcohol illegal again, I'd abstain
because I like my job too much to lose it over something so trivial.

Cigarettes? Wouldn't touch 'em regardless of what the law says.

Barb May

7/27/2013 2:57:00 AM

0

anim8rFSK wrote:
> In article <k0r5v8li2mg7s2egofcpg08n2s9611ib3m@4ax.com>,
> Mason Barge <masonbarge@gmail.com> wrote:
>
>> On Fri, 26 Jul 2013 12:26:04 -0700, "BTR1701"
>> <a54b123@webnntp.invalid> wrote:
>>
>>> On Jul 26 2013 8:18 AM, Adam H. Kerman wrote:
>>>
>>>> BTR1701 <atropos@mac.com> wrote:
>>>>> "Adam H. Kerman" <ahk@chinet.com> wrote:
>>>>>> BTR1701 <atropos@mac.com> wrote:
>>>>>>> "Barb May" <barbmay@nonofyourbusinessx.tv> wrote:
>>>>>>>> Mason Barge wrote:
>>>>
>>>>>>>>> So, maybe a few black leaders will say, "you know what, if we
>>>>>>>>> worried more about what these black criminals are doing to
>>>>>>>>> our black community
>>>>>>>>> and stop trying to blame white people, we might actually
>>>>>>>>> improve things."
>>>>
>>>>>>>> Sure, let's all stop blaming white people for the mass
>>>>>>>> incarceration of
>>>>>>>> blacks. After all, It's really their own fault because they are
>>>>>>>> morally
>>>>>>>> weak and because of black leaders who promote a sense of
>>>>>>>> victimhood within the black community.
>>>>
>>>>>>> Then it's amazing that they can't seem to obey the same laws as
>>>>>>> everyone
>>>>>>> else. I mean, we're told these drug laws are racist, but I've
>>>>>>> managed to
>>>>>>> go my whole life without ever smoking marijuana, snorting coke,
>>>>>>> or smoking crack. How is it my fault if someone else can't
>>>>>>> manage to do the
>>>>>>> same?
>>>>
>>>>>> Tell us how you grew up a poor black boy in the ghetto
>>>>
>>>>> There are plenty of poor black boys in the ghetto who manage to
>>>>> not be criminals also.
>>>>
>>>> Yeah. They had decent parents and didn't live in circumstances
>>>> that were so dire that they turned to drugs to escape. Tell us how
>>>> many there are who didn't.
>>>
>>> Ah, so what you're saying is that they chose to commit crime. For
>>> every one you show me that turned to crime to "escape" their bad
>>> life, I can show you many who didn't.
>>>
>>>> Out of curiousity, shouldn't drug use be considered a victimless
>>>> crime?
>>>
>>> I think so. Until it is, however, I obey the law.
>>
>> Oh, bullshit. As long as my tax dollars are paying for their medical
>> care, all of their illegitimate spawn, buying them cell phones,
>> subsidizing their rent, blah blah blah, I am a victim of their drug
>> addiction.
>>
>> Plus, even if drugs were legal, do you think there wouldn't be people
>> burglarizing houses for money to buy drugs?
>>
>> You ever see a baby born to an addict mother? There's another victim
>> right there.
>
> I'm also from the 'there will be carnage on the road' school as well,
> since I know too many people that insist weed and coke don't impair
> their driving at all, and only don't use and drive because they don't
> want to get caught.

Your comment is even more clueless and nonsensical as anything you would
claim justifies the insult in your sig. I won't bother explaining why
so you won't have to put up some kind of lame defense. Just goes to show
that "even you" can say something really stupid once in a while, perhaps
even more often than those you ridicule. People who live in glass
houses...

--
Barb


Thanatos

7/27/2013 4:10:00 AM

0

In article <anim8rfsk-21643B.18523526072013@news.easynews.com>,
anim8rFSK <anim8rfsk@cox.net> wrote:

> In article <69abcaxcpv.ln2@news.ezprovider.com>,
> "BTR1701" <a54b123@webnntp.invalid> wrote:
>
> > On Jul 26 2013 2:42 PM, Mason Barge wrote:

> > > You ever see a baby born to an addict mother? There's another victim
> > > right there.
> >
> > The make all drugs illegal. Nicotine, caffeine, the whole bunch.
> >
> > But this idiocy where we allow people to legally smoke cigs and booze it
> > up and become just addicted and dangerous to society on the one hand, but
> > lock people up for smoking some weed on the other, is schizophrenic and
> > illogical and frankly I'm sick of paying a shit-ton of taxes for the $10
> > billion/year marijuana interdiction effort which has done fuck-all to stop
> > people from buying, selling, and using marijuana.
>
> While I agree with you in principle, I don't buy the 'this drug is legal
> so we should make them all legal' school of thought.

I'm not a crusader for legalizing all drugs, but if you take pot out of
the equation, you kill off about 75% of this useless and ridiculously
expensive "War on Drugs" with one swipe.

Anim8rFSK

7/27/2013 6:34:00 AM

0

In article <atropos-6891C1.21101626072013@news-europe.giganews.com>,
BTR1701 <atropos@mac.com> wrote:

> In article <anim8rfsk-21643B.18523526072013@news.easynews.com>,
> anim8rFSK <anim8rfsk@cox.net> wrote:
>
> > In article <69abcaxcpv.ln2@news.ezprovider.com>,
> > "BTR1701" <a54b123@webnntp.invalid> wrote:
> >
> > > On Jul 26 2013 2:42 PM, Mason Barge wrote:
>
> > > > You ever see a baby born to an addict mother? There's another victim
> > > > right there.
> > >
> > > The make all drugs illegal. Nicotine, caffeine, the whole bunch.
> > >
> > > But this idiocy where we allow people to legally smoke cigs and booze it
> > > up and become just addicted and dangerous to society on the one hand, but
> > > lock people up for smoking some weed on the other, is schizophrenic and
> > > illogical and frankly I'm sick of paying a shit-ton of taxes for the $10
> > > billion/year marijuana interdiction effort which has done fuck-all to stop
> > > people from buying, selling, and using marijuana.
> >
> > While I agree with you in principle, I don't buy the 'this drug is legal
> > so we should make them all legal' school of thought.
>
> I'm not a crusader for legalizing all drugs, but if you take pot out of
> the equation, you kill off about 75% of this useless and ridiculously
> expensive "War on Drugs" with one swipe.

I just watched the FAMILY GUY where they legalized pot and it all went
horribly awry and cost Lois' father billions and they had to make it
illegal again. Plus they called people that like "The Rocketeer" stupid.

--
Wait - are you saying that ClodReamer was wrong, or lying?

trotsky

7/27/2013 12:17:00 PM

0

On 7/26/13 11:10 PM, BTR1701 wrote:
> In article <anim8rfsk-21643B.18523526072013@news.easynews.com>,
> anim8rFSK <anim8rfsk@cox.net> wrote:
>
>> In article <69abcaxcpv.ln2@news.ezprovider.com>,
>> "BTR1701" <a54b123@webnntp.invalid> wrote:
>>
>>> On Jul 26 2013 2:42 PM, Mason Barge wrote:
>
>>>> You ever see a baby born to an addict mother? There's another victim
>>>> right there.
>>>
>>> The make all drugs illegal. Nicotine, caffeine, the whole bunch.
>>>
>>> But this idiocy where we allow people to legally smoke cigs and booze it
>>> up and become just addicted and dangerous to society on the one hand, but
>>> lock people up for smoking some weed on the other, is schizophrenic and
>>> illogical and frankly I'm sick of paying a shit-ton of taxes for the $10
>>> billion/year marijuana interdiction effort which has done fuck-all to stop
>>> people from buying, selling, and using marijuana.
>>
>> While I agree with you in principle, I don't buy the 'this drug is legal
>> so we should make them all legal' school of thought.
>
> I'm not a crusader for legalizing all drugs, but if you take pot out of
> the equation, you kill off about 75% of this useless and ridiculously
> expensive "War on Drugs" with one swipe.


That's not an official teabagger response.


--
Never post something on the internet unless you have a point of
reference. You will look like a moron otherwise.