Re: [racket-users] Matrix Indexing Operations in "math/matrix"

2018-10-07 Thread Sam Tobin-Hochstadt
The `math/matrix` library aims at functional arrays, that is arrays
that aren't mutated but are instead transformed into new arrays.

However, if you want mutable arrays, then you should probably use the
`mutable-array` constructor to create them, and then `array-set!` will
work.

Sam
On Sun, Oct 7, 2018 at 10:56 AM Ricardo Iglesias
 wrote:
>>
>> >I think you want the `matrix-ref` function.
>
> While this does give me the value, I am unable to set it.
>
> Calling
> (define M (matrix ([1 2 3] [4 5 6])))
> (set! (matrix-ref M 0 2) 5)
>
> Leads to the error:
> ; .../Example.rkt:228:6: set!: not an identifier
>
> -
> And array-set! for changing the value of an entry.
> What would be the syntax for that? I noticed that a requirement for using 
> array-set! is that the array passed in needs to be a settable array, and that 
> the matrices in math/matrix are not such a type of array.
>
> I get this error:
>  array-set!: contract violation
> ;   expected: Settable-Array?
> ;   given: (array #[#[1 2 3]])
> ;   in: the 1st argument of
> ;   (->
> ;(struct/c
> ; Settable-Array
> ; (vectorof Index)
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Matrix Indexing Operations in "math/matrix"

2018-10-07 Thread Ricardo Iglesias

>
> >I think you want the `matrix-ref` function. 
>
While this does give me the value, I am unable to set it. 

Calling 
(define M (matrix ([1 2 3] [4 5 6])))
(set! (matrix-ref M 0 2) 5)

Leads to the error:
; .../Example.rkt:228:6: set!: not an identifier

-
And array-set! for changing the value of an entry.
What would be the syntax for that? I noticed that a requirement for using 
array-set! is that the array passed in needs to be a settable array, and 
that the matrices in math/matrix are not such a type of array. 

I get this error: 
 array-set!: contract violation
;   expected: Settable-Array?
;   given: (array #[#[1 2 3]])
;   in: the 1st argument of
;   (->
;(struct/c
; Settable-Array
; (vectorof Index)



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Matrix Indexing Operations in "math/matrix"

2018-10-07 Thread Jens Axel Søgaard
And array-set! for changing the value of an entry.

/Jens Axel


Den søn. 7. okt. 2018 kl. 16.46 skrev Sam Tobin-Hochstadt <
sa...@cs.indiana.edu>:

> I think you want the `matrix-ref` function.
>
> Sam
> On Sun, Oct 7, 2018 at 12:30 AM Ricardo Iglesias
>  wrote:
> >
> > Sorry for the confusing wording.
> > Basically, All I want is to be able to do
> > G[ row ][ col ] = value
> >
> > In Racket. I've been messing with Racket this afternoon and have an
> engine that is able to index into matrices, and just implemented several
> common matrix operations, such as transpose, matrix multiplication, etc...,
> so for now, I'm good.
> >
> >
> > On Saturday, October 6, 2018 at 8:47:41 PM UTC-7, cwebber wrote:
> >>
> >> Ricardo Iglesias writes:
> >>
> >> > Good afternoon. I'm trying to move away from things like Matlab and
> SciPy
> >> > to do linear algebra work.
> >> > Something I notice I do a lot is indexing operations, such as
> >> > MATRIX[ row ] [ column ]
> >> >
> >> > I'm looking at the "math/matrix" library provided here:
> >> > https://docs.racket-lang.org/math/matrices.html, and don't see
> anything of
> >> > this sort; I only see things like
> >> > (matrix-map-rows)
> >> >
> >> > and
> >> > (matrix-map-cols)
> >> >
> >> > Being able to access and modify a particular entry in the matrix
> would be
> >> > very useful in specifying operations to matrices. For example, given a
> >> > matrix *G*, one might want to perform indexing operations to get the
> matrix
> >> > attached.
> >> >
> >> > Is this possible with the math/matrix library?
> >> >
> >> > Additionally, would there be a way to implement a version of
> >> > matrix-map-row/cols that uses an index?
> >>
> >> Not quite what you're asking, but someone at RacketCon suggested to me
> >> that maybe we should get GNU Scientific Library bindings added to
> >> Racket, so we can better compete with Python and R for scientific /
> >> statistical work...
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Matrix Indexing Operations in "math/matrix"

2018-10-07 Thread Sam Tobin-Hochstadt
I think you want the `matrix-ref` function.

Sam
On Sun, Oct 7, 2018 at 12:30 AM Ricardo Iglesias
 wrote:
>
> Sorry for the confusing wording.
> Basically, All I want is to be able to do
> G[ row ][ col ] = value
>
> In Racket. I've been messing with Racket this afternoon and have an engine 
> that is able to index into matrices, and just implemented several common 
> matrix operations, such as transpose, matrix multiplication, etc..., so for 
> now, I'm good.
>
>
> On Saturday, October 6, 2018 at 8:47:41 PM UTC-7, cwebber wrote:
>>
>> Ricardo Iglesias writes:
>>
>> > Good afternoon. I'm trying to move away from things like Matlab and SciPy
>> > to do linear algebra work.
>> > Something I notice I do a lot is indexing operations, such as
>> > MATRIX[ row ] [ column ]
>> >
>> > I'm looking at the "math/matrix" library provided here:
>> > https://docs.racket-lang.org/math/matrices.html, and don't see anything of
>> > this sort; I only see things like
>> > (matrix-map-rows)
>> >
>> > and
>> > (matrix-map-cols)
>> >
>> > Being able to access and modify a particular entry in the matrix would be
>> > very useful in specifying operations to matrices. For example, given a
>> > matrix *G*, one might want to perform indexing operations to get the matrix
>> > attached.
>> >
>> > Is this possible with the math/matrix library?
>> >
>> > Additionally, would there be a way to implement a version of
>> > matrix-map-row/cols that uses an index?
>>
>> Not quite what you're asking, but someone at RacketCon suggested to me
>> that maybe we should get GNU Scientific Library bindings added to
>> Racket, so we can better compete with Python and R for scientific /
>> statistical work...
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Matrix Indexing Operations in "math/matrix"

2018-10-06 Thread Ricardo Iglesias
Sorry for the confusing wording. 
Basically, All I want is to be able to do 
G[ row ][ col ] = value

In Racket. I've been messing with Racket this afternoon and have an engine 
that is able to index into matrices, and just implemented several common 
matrix operations, such as transpose, matrix multiplication, etc..., so for 
now, I'm good. 


On Saturday, October 6, 2018 at 8:47:41 PM UTC-7, cwebber wrote:
>
> Ricardo Iglesias writes: 
>
> > Good afternoon. I'm trying to move away from things like Matlab and 
> SciPy 
> > to do linear algebra work. 
> > Something I notice I do a lot is indexing operations, such as 
> > MATRIX[ row ] [ column ] 
> > 
> > I'm looking at the "math/matrix" library provided here: 
> > https://docs.racket-lang.org/math/matrices.html, and don't see anything 
> of 
> > this sort; I only see things like 
> > (matrix-map-rows) 
> > 
> > and 
> > (matrix-map-cols) 
> > 
> > Being able to access and modify a particular entry in the matrix would 
> be 
> > very useful in specifying operations to matrices. For example, given a 
> > matrix *G*, one might want to perform indexing operations to get the 
> matrix 
> > attached. 
> > 
> > Is this possible with the math/matrix library? 
> > 
> > Additionally, would there be a way to implement a version of 
> > matrix-map-row/cols that uses an index? 
>
> Not quite what you're asking, but someone at RacketCon suggested to me 
> that maybe we should get GNU Scientific Library bindings added to 
> Racket, so we can better compete with Python and R for scientific / 
> statistical work... 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Matrix Indexing Operations in "math/matrix"

2018-10-06 Thread Christopher Lemmer Webber
Ricardo Iglesias writes:

> Good afternoon. I'm trying to move away from things like Matlab and SciPy 
> to do linear algebra work. 
> Something I notice I do a lot is indexing operations, such as 
> MATRIX[ row ] [ column ]
>
> I'm looking at the "math/matrix" library provided here: 
> https://docs.racket-lang.org/math/matrices.html, and don't see anything of 
> this sort; I only see things like 
> (matrix-map-rows) 
>
> and 
> (matrix-map-cols)
>
> Being able to access and modify a particular entry in the matrix would be 
> very useful in specifying operations to matrices. For example, given a 
> matrix *G*, one might want to perform indexing operations to get the matrix 
> attached. 
>
> Is this possible with the math/matrix library? 
>
> Additionally, would there be a way to implement a version of 
> matrix-map-row/cols that uses an index? 

Not quite what you're asking, but someone at RacketCon suggested to me
that maybe we should get GNU Scientific Library bindings added to
Racket, so we can better compete with Python and R for scientific /
statistical work...

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Matrix Indexing Operations in "math/matrix"

2018-10-06 Thread Ricardo Iglesias
Good afternoon. I'm trying to move away from things like Matlab and SciPy 
to do linear algebra work. 
Something I notice I do a lot is indexing operations, such as 
MATRIX[ row ] [ column ]

I'm looking at the "math/matrix" library provided here: 
https://docs.racket-lang.org/math/matrices.html, and don't see anything of 
this sort; I only see things like 
(matrix-map-rows) 

and 
(matrix-map-cols)

Being able to access and modify a particular entry in the matrix would be 
very useful in specifying operations to matrices. For example, given a 
matrix *G*, one might want to perform indexing operations to get the matrix 
attached. 

Is this possible with the math/matrix library? 

Additionally, would there be a way to implement a version of 
matrix-map-row/cols that uses an index? 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.