COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### generalization of matrix product?

• Email
• Follow

```Hi,
Suppose we have two matrices
R = [r1
r2]
and
C = [c1 c2],
where r1 and r2 are row vectors and c1 and c2 are column vectors of equal length.
The standard matrix product R*C can be viewed as
[dot(r1, c1) dot(r1, c2)
dot(r2, c1) dot(r2, c2)]
clearly this extends to any number of rows in R and columns in C.

Is there a neat way in matlab to perform an operation between two matrices similar to the above where the dot() function is replaced by a user defined function between two vectors?
```
 0

See related articles to this posting

```"A " <aaarbk@geemail.com> wrote in message <hr7rqd\$9vj\$1@fred.mathworks.com>...
> Hi,
> Suppose we have two matrices
> R = [r1
>        r2]
> and
> C = [c1 c2],
> where r1 and r2 are row vectors and c1 and c2 are column vectors of equal length.
> The standard matrix product R*C can be viewed as
> [dot(r1, c1) dot(r1, c2)
>  dot(r2, c1) dot(r2, c2)]
> clearly this extends to any number of rows in R and columns in C.
>
> Is there a neat way in matlab to perform an operation between two matrices similar to the above where the dot() function is replaced by a user defined function between two vectors?

help bsxfun

For example...

fun = @(x,y) x.^2 + y.^2;
x = [1;2;3];
y = [2 3 5 7];
bsxfun(fun,x,y)
ans =
5    10    26    50
8    13    29    53
13    18    34    58

John
```
 0

```"John D'Errico" <woodchips@rochester.rr.com> wrote in message <hr7vej\$hq\$1@fred.mathworks.com>...
> "A " <aaarbk@geemail.com> wrote in message <hr7rqd\$9vj\$1@fred.mathworks.com>...
> > Hi,
> > Suppose we have two matrices
> > R = [r1
> >        r2]
> > and
> > C = [c1 c2],
> > where r1 and r2 are row vectors and c1 and c2 are column vectors of equal length.
> > The standard matrix product R*C can be viewed as
> > [dot(r1, c1) dot(r1, c2)
> >  dot(r2, c1) dot(r2, c2)]
> > clearly this extends to any number of rows in R and columns in C.
> >
> > Is there a neat way in matlab to perform an operation between two matrices similar to the above where the dot() function is replaced by a user defined function between two vectors?
>
> help bsxfun
>
> For example...
>
> fun = @(x,y) x.^2 + y.^2;
> x = [1;2;3];
> y = [2 3 5 7];
> bsxfun(fun,x,y)
> ans =
>      5    10    26    50
>      8    13    29    53
>    13    18    34    58
>
> John

Hi John,
Thank you for your response. I am familiar with bsxfun and its application to the sort of example you have shown. However, in my example there is no "singleton" dimension; the matrices R and C satisfy the same size requirements as those for a general matrix product (although it might be possible in a more general setting to do away with even this requirement).
So for example:
A is a matrix of size n*d, storing a collection of n d-dimensional points, and define
euc = @(x,y) norm(x-y)
so
whatIwant(euc, A,A')
would return the Euclidean distance matrix between every pair of points in A.
```
 0

2 Replies
120 Views

Similar Articles

12/11/2013 6:09:18 PM
[PageSpeed]

Similar Artilces:

The generalized Hessian matrix is not positive definit
When I use GEE to do logistic regression, this sas give me the message:The generalized Hessian matrix is not positive definit. what's wrong with my data? Help! ...

How general is general intelligence?
There are some grounds to say that even we are not general intelligences. One reason is that very small and uncomplex random number generators can generate very complex looking data, where we don't see any pattern, even though it is there. Or think about some nice fractal, where we can see some patterns and redundancy, but not in such a way that we could have any sense of how short is the algorithm that made it. Those are extreme examples that should make us ask, where are the theoretical and practical limits of generality for so called general intelligences? That is related to the quest...

New product from CMS Products
They just announced a 100GB backup drive. List is at \$419. Has anyone ever used their backup systems? I'm thinking of getting one of these and upgrading my laptop to 100GB. Thanks! ...

Matrix
Needed MATRIX for software testing Web based application. I just started to work in the company. Please reply to me if you wish to help me with this issue. Thanks so much. Regards, Michael. Our book "Quality Web Systems" will provide you with a checklist for web testing. see http://www.qualitywebsys.com There are also some web testing checklists available free, including discussions surrounding the topic on http://www.qaforums.com Good luck, Elfriede Dustin http://www.effectivesoftwaretesting.com >Subject: Matrix >From: m15s@hotmail.com (MichaelS) >Date: 7/17/03 8:08 ...

Director - Product Management- Montreal - 2 Positions - 1 - B2B Products - 1
This is a multi-part message in MIME format. ------=_NextPart_000_054F_01C3AADB.B6FF4BD0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Director - Product Management- Montreal - 2 Positions - 1 - B2B Products = - 1 - B2C Products Client in Montr=E9al looking for 2 Directors of Product Management. 1. B2B Focus - Web Services, Back end Management Tools, Web Services = Marketing, Internet Access - delivered to ISPs/Carriers =20 2. B2C Focus - VPN, Firewalls, Internet Access to Consumers. =20 =20 Both Jobs would entail the following ...

Creating matrix from another matrix using column position
Hello everyone here..... I have problem here, I have a matrix 16x24, lets call it matrix A. There is Matrix B 24x24 which depend on the reading row and column with values from Matrix A. Here are link for matrix A: https://docs.google.com/file/d/0B-dcMNCq0QF8OTdPMS1WRVNxb1k/edit?usp=sharing After that, I want to create matrix C, consist of matrix 150x150. The rule are below here: 1. Matrix C formed from matrix A. 2. Each row and column from matrix C are read the values from matrix A for each row, not the entire matrix. If there is no values from matrix A (based on the tables...

How to change alignment of Grid/Matrix created using menu (Insert->Matrix/Table->New)
When creating a Grid using Insert->Table/Matrix->New->Table, and then entering data into the grid, I'd like it to be left aligned, instead of the default now which is centered. It looked like what actually happens is that this is all done by FE since the FullForm shows it is just list of lists and there is no Grid around it. i.e. it is not really the same thing as when using the command Grid but just a visual emulation. I also did SetOptions[Grid, Alignment -> {Left, Baseline}] before creating the Grid using the menu, and it made no difference, it was still centere...

US-TX-Austin: Product Eng., BSEE with 2.5yrs working as a Product Eng.; Perm (45343757617)
US-TX-Austin: Product Eng., BSEE with 2.5yrs working as a Product Eng.; Perm (45343757617) ========================================================================================== Position: Product Eng. Reference: SMC01903 Location: Austin TX Duration: Perm Skills: REQUIREMENTS: BSEE with 2.5 years working as a Product Engineer Scope: DUTIES AND RESPONSIBILITIES: Person will be responsible for the design, implementation and monitoring of test and reliability hardware, validation of first silicon and revis...

US-TX-Austin: Product Characterization Eng. RF test/product exp., VB, C or C#; P (45340932412)
US-TX-Austin: Product Characterization Eng. RF test/product exp., VB, C or C#; P (45340932412) ============================================================================================== Position: Product Characterization Eng. Reference: SMC01920 Location: Austin TX Duration: Perm Skills: Qualifications � MSEE or BSEE � 0-5 years in RF test/product experience. � Strong software development background. � Strong written / verbal communication & presentation skills. � Strong troublesh...

US-TX-Austin: Product Characterization Eng. RF test/product exp., VB, C or C#; P (45342457610)
US-TX-Austin: Product Characterization Eng. RF test/product exp., VB, C or C#; P (45342457610) ============================================================================================== Position: Product Characterization Eng. Reference: SMC01920 Location: Austin TX Duration: Perm Skills: Qualifications � MSEE or BSEE � 0-5 years in RF test/product experience. � Strong software development background. � Strong written / verbal communication & presentation skills. � Strong troublesh...

Definition of Production
Hi all, I'm looking for a clear definition of `production' in a (computer) grammatic/syntactic context. I've seen it used to mean anything from rule (in the xBNF sense) to input string, to mixtures of both (e.g. the segment of the input that matched a given rule). I would like to know if there is more precise definition, and an example or two if possible :). A related question is whether `production' == `production rule'. Thanks in advance for the help. Cheers, -Al- [No terms in comp sci have precise definitions, but I've consistently seen production used in the sens...

I post these two references because (a) they are probably of use to some people; and (b) a routine search of Wikipedia (or Google, for that matter) might not necessarily include them in search results. http://en.wikipedia.org/wiki/Comparison_of_Usenet_newsreaders http://en.wikipedia.org/wiki/List_of_Usenet_newsreaders The two things that were of note to me are (a) Thoth is not included; and (b) No newsreader-for-Mac seems to include all of the tabulated features. (Although what does the absence of _both_ green and pink labels mean?) Windows users might presumably choose NewsBin ...

matrix formation
hi, without the use of permutation. here i want to make a M matrix which contains 'n' numbers. in this example number exits are(1,2,3,4,5). M=1 1 1 1 1 2 1 1 3 1 1 4 1 1 5 1 2 2 1 2 3 1 2 4 1 2 5 1 3 3 1 3 4 1 4 4 2 2 2 2 2 3 2 2 4 2 3 3 2 3 4 3 3 3 help me pl...

Matrix Comparrison
I am trying to compare two matrices and store the contents of one if it corresponds to the number one in the second matrix. ie. from the two matrixes A = [0 0 1, 1 0 0, 0 1 0] and B = [1 2 3, 4 5 6, 7 8 9] i want a way of returning a matrix C which contains 3,4 and 8 in the form C = [3 4 8]. i have managed to implement a method of doing this using for loops but am trying to find another way as i am working with matrixes of dimensions 500 x 800 and bigger. is there a quicker, more efficient method? my method with for loops is k = 1 for i = 1:500 for j = 1:8...

Productivity Gains
[From the XP mailing list] Hi, Look at the URL: http://www.nzherald.co.nz/index.cfm?c_id=5&ObjectID=10113120 <quote> Engberg said since then developer numbers had declined to 150 because of a hiring freeze, but productivity had doubled because of the adoption of the extreme programming methodology and new development tools. "When people left, we didn't backfill because productivity was increasing and we were waiting for the market to turn around," he said. </quote> Thanks and Regards KD -- Dakshinamurthy Karra CTO, Subex Systems Ltd.(http://www.subexsystems....