Apply function to elements of a matrix column
08-30-2015, 10:54 AM (This post was last modified: 08-30-2015 10:55 AM by DrD.)
Post: #1
 DrD Senior Member Posts: 1,132 Joined: Feb 2014
Apply function to elements of a matrix column
Replace column 5, element by element, with its absolute value:

M0:=[[1,1,0,1,2,1,0,0],[1,2,1,2,-5,0,0,1],[1,3,2,3,-6,0,0,1],[1,4,3,0,-3,0,0,1],[2,1,3,2,-6,0,0,1],[2,2,2,4,-2,0,0,1],[2,3,4,5,-5,0,0,1],[2,4,5,3,4,1,0,0],[3,1,5,4,5,0,0,1],[3,2,4,6,-2,0,0,1],[3,3,6,7,-8,0,0,1],[3,4,7,5,-8,1,0,0]];

desired result:

M0:=[[1,1,0,1,2,1,0,0],[1,2,1,2,5,0,0,1],[1,3,2,3,6,0,0,1],[1,4,3,0,3,0,0,1],[2,1,3,2,6,0,0,1],[2,2,2,4,2,0,0,1],[2,3,4,5,5,0,0,1],[2,4,5,3,4,1,0,0],[3,1,5,4,5,0,0,1],[3,2,4,6,2,0,0,1],[3,3,6,7,8,0,0,1],[3,4,7,5,8,1,0,0]];

This has been my best success, but is there a simpler way to apply a function to the elements of a column (or row)?:

[CAS]
M0(-5):=apply((x)->ABS(x),M0(-5));

-Dale-
 « Next Oldest | Next Newest »

 Messages In This Thread Apply function to elements of a matrix column - DrD - 08-30-2015 10:54 AM RE: Apply function to elements of a matrix column - roadrunner - 08-30-2015, 09:06 PM RE: Apply function to elements of a matrix column - DrD - 08-31-2015, 10:58 AM RE: Apply function to elements of a matrix column - leprechaun - 08-31-2015, 08:26 AM RE: Apply function to elements of a matrix column - roadrunner - 08-31-2015, 03:07 PM RE: Apply function to elements of a matrix column - roadrunner - 08-31-2015, 02:08 PM