Hi, Try this: #mat1 is the data res<-do.call(cbind,lapply(seq_len(nrow(mat1)),function(i) {new1<-do.call(rbind,lapply(seq_len(nrow(mat1[-i,])),function(j) {x1<-rbind(mat1[i,],mat1[j,]); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2,3])*abs(x1[1,7]-x1[2,7]))+(abs(x1[1,4]-x1[2,4])*abs(x1[1,8]-x1[2,8]))}));new1})) head(res,3) #??? [,1]?? [,2]?? [,3]?? [,4]?? [,5]?? [,6]?? [,7]?? [,8]?? [,9]? [,10] #[1,]????? 0? 79745 146483? 40874 206818 229688 149126 230028? 90188 157418 #[2,]? 79745????? 0 117950 179977 187223 343090 119664 137120 134010? 74077 #[3,] 146483 117950????? 0 123746? 54717 124372 132140? 36383? 70878 112656 ----------------------------------------------------------------------------------- A.K. ________________________________ From: eliza botto <eliza_botto at hotmail.com> To: "smartpink111 at yahoo.com" <smartpink111 at yahoo.com> Sent: Wednesday, February 27, 2013 8:47 AM Subject: RE: matrix multiplication there you go>dput(eliza)structure(c(428L, 359L, 353L, 498L, 169L, 46L, 29L, 444L, 194L,? 439L, 284L, 79L, 226L, 105L, 106L, 326L, 234L, 196L, 417L, 190L,? 480L, 275L, 478L, 341L, 197L, 395L, 85L, 295L, 70L, 18L, 471L,? 218L, 19L, 43L, 280L, 427L, 229L, 5L, 205L, 494L, 393L, 307L,? 465L, 383L, 265L, 103L, 348L, 166L, 58L, 320L, 14L, 107L, 440L,? 24L, 347L, 419L, 135L, 202L, 294L, 173L, 121L, 358L, 51L, 231L,? 118L, 109L, 182L, 219L, 42L, 73L, 435L, 389L, 431L, 81L, 149L,? 388L, 415L, 256L, 312L, 446L, 45L, 162L, 485L, 154L, 55L, 153L,? 137L, 290L, 93L, 40L, 110L, 167L, 315L, 266L, 317L, 314L, 264L,? 277L, 488L, 28L, 354L, 303L, 490L, 192L, 432L, 228L, 222L, 418L,? 323L, 244L, 239L, 193L, 120L, 116L, 148L, 57L, 246L, 300L, 143L,? 208L, 400L, 78L, 273L, 411L, 401L, 476L, 262L, 159L, 195L, 102L,? 75L, 136L, 402L, 32L, 199L, 286L, 477L, 54L, 429L, 80L, 316L,? 30L, 333L, 387L, 452L, 324L, 456L, 39L, 138L, 113L, 448L, 377L,? 122L, 441L, 396L, 454L, 497L, 161L, 21L, 117L, 413L, 94L, 459L,? 156L, 365L, 322L, 397L, 88L, 207L, 150L, 209L, 184L, 378L, 217L,? 176L, 52L, 374L, 189L, 97L, 340L, 357L, 157L, 220L, 74L, 356L,? 495L, 453L, 26L, 499L, 364L, 267L, 331L, 245L, 258L, 242L, 381L,? 36L, 16L, 328L, 131L, 255L, 363L, 298L, 373L, 416L, 200L, 56L,? 263L, 288L, 13L, 305L, 291L, 17L, 53L, 130L, 458L, 385L, 198L,? 158L, 140L, 492L, 249L, 27L, 134L, 479L, 171L, 177L, 9L, 355L,? 398L, 380L, 404L, 304L, 129L, 338L, 281L, 65L, 386L, 144L, 252L,? 77L, 352L, 20L, 96L, 403L, 296L, 268L, 489L, 63L, 424L, 496L,? 126L, 334L, 183L, 232L, 406L, 407L, 163L, 346L, 287L, 475L, 127L,? 321L, 124L, 237L, 308L, 376L, 212L, 423L, 211L, 329L, 437L, 179L,? 253L, 372L, 101L, 251L, 90L, 433L, 311L, 241L, 327L, 422L, 349L,? 493L, 442L, 38L, 449L, 410L, 370L, 421L, 325L, 451L, 240L, 71L,? 392L, 2L, 151L, 332L, 83L, 350L, 87L, 361L, 330L, 279L, 362L,? 310L, 487L, 278L, 367L, 248L, 462L, 59L, 213L, 68L, 112L, 60L,? 481L, 165L, 235L, 22L, 434L, 272L, 460L, 309L, 301L, 500L, 282L,? 82L, 100L, 261L, 34L, 188L, 133L, 344L, 7L, 486L, 67L, 399L,? 254L, 41L, 483L, 64L, 405L, 108L, 236L, 384L, 467L, 49L, 283L,? 119L, 463L, 147L, 379L, 216L, 474L, 204L, 48L, 260L, 12L, 337L,? 187L, 271L, 31L, 289L, 172L, 35L, 408L, 164L, 91L, 351L, 443L,? 436L, 469L, 186L, 472L, 297L, 50L, 425L, 224L, 3L, 221L, 11L,? 391L, 33L, 243L, 247L, 152L, 98L, 482L, 111L, 257L, 155L, 47L,? 10L, 468L, 270L, 313L, 86L, 293L, 160L, 168L, 409L, 170L, 84L,? 180L, 76L, 99L, 214L, 15L, 414L, 394L, 450L, 4L, 61L, 339L, 342L,? 1L, 470L, 210L, 37L, 345L, 115L, 141L, 302L, 178L, 445L, 6L,? 466L, 285L, 174L, 201L, 114L, 369L, 390L, 69L, 420L, 464L, 269L,? 455L, 382L, 25L, 123L, 95L, 230L, 72L, 250L, 473L, 8L, 274L,? 238L, 62L, 461L, 104L, 125L, 128L, 227L, 292L, 430L, 206L, 360L,? 491L, 191L, 142L, 181L, 318L, 484L, 145L, 89L, 233L, 368L, 412L,? 335L, 215L, 146L, 139L, 426L, 375L, 66L, 299L, 438L, 223L, 175L,? 92L, 225L, 276L, 185L, 336L, 371L, 306L, 366L, 319L, 203L, 44L,? 259L, 23L, 132L, 343L, 447L, 457L, 428L, 359L, 353L, 498L, 169L,? 46L, 29L, 444L, 194L, 439L, 284L, 79L, 226L, 105L, 106L, 326L,? 234L, 196L, 417L, 190L, 480L, 275L, 478L, 341L, 197L, 395L, 85L,? 295L, 70L, 18L, 471L, 218L, 19L, 43L, 280L, 427L, 229L, 5L, 205L,? 494L, 393L, 307L, 465L, 383L, 265L, 103L, 348L, 166L, 58L, 320L,? 14L, 107L, 440L, 24L, 347L, 419L, 135L, 202L, 294L, 173L, 121L,? 358L, 51L, 231L, 118L, 109L, 182L, 219L, 42L, 73L, 435L, 389L,? 431L, 81L, 149L, 388L, 415L, 256L, 312L, 446L, 45L, 162L, 485L,? 154L, 55L, 153L, 137L, 290L, 93L, 40L, 110L, 167L, 315L, 266L,? 317L, 314L, 264L, 277L, 488L, 28L, 354L, 303L, 490L, 192L, 432L,? 228L, 222L, 418L, 323L, 244L, 239L, 193L, 120L, 116L, 148L, 57L,? 246L, 300L, 143L, 208L, 400L, 78L, 273L, 411L, 401L, 476L, 262L,? 159L, 195L, 102L, 75L, 136L, 402L, 32L, 199L, 286L, 477L, 54L,? 429L, 80L, 316L, 30L, 333L, 387L, 452L, 324L, 456L, 39L, 138L,? 113L, 448L, 377L, 122L, 441L, 396L, 454L, 497L, 161L, 21L, 117L,? 413L, 94L, 459L, 156L, 365L, 322L, 397L, 88L, 207L, 150L, 209L,? 184L, 378L, 217L, 176L, 52L, 374L, 189L, 97L, 340L, 357L, 157L,? 220L, 74L, 356L, 495L, 453L, 26L, 499L, 364L, 267L, 331L, 245L,? 258L, 242L, 381L, 36L, 16L, 328L, 131L, 255L, 363L, 298L, 373L,? 416L, 200L, 56L, 263L, 288L, 13L, 305L, 291L, 17L, 53L, 130L,? 458L, 385L, 198L, 158L, 140L, 492L, 249L, 27L, 134L, 479L, 171L,? 177L, 9L, 355L, 398L, 380L, 404L, 304L, 129L, 338L, 281L, 65L,? 386L, 144L, 252L, 77L, 352L, 20L, 96L, 403L, 296L, 268L, 489L,? 63L, 424L, 496L, 126L, 334L, 183L, 232L, 406L, 407L, 163L, 346L,? 287L, 475L, 127L, 321L, 124L, 237L, 308L, 376L, 212L, 423L, 211L,? 329L, 437L, 179L, 253L, 372L, 101L, 251L, 90L, 433L, 311L, 241L,? 327L, 422L, 349L, 493L, 442L, 38L, 449L, 410L, 370L, 421L, 325L,? 451L, 240L, 71L, 392L, 2L, 151L, 332L, 83L, 350L, 87L, 361L,? 330L, 279L, 362L, 310L, 487L, 278L, 367L, 248L, 462L, 59L, 213L,? 68L, 112L, 60L, 481L, 165L, 235L, 22L, 434L, 272L, 460L, 309L,? 301L, 500L, 282L, 82L, 100L, 261L, 34L, 188L, 133L, 344L, 7L,? 486L, 67L, 399L, 254L, 41L, 483L, 64L, 405L, 108L, 236L, 384L,? 467L, 49L, 283L, 119L, 463L, 147L, 379L, 216L, 474L, 204L, 48L,? 260L, 12L, 337L, 187L, 271L, 31L, 289L, 172L, 35L, 408L, 164L,? 91L, 351L, 443L, 436L, 469L, 186L, 472L, 297L, 50L, 425L, 224L,? 3L, 221L, 11L, 391L, 33L, 243L, 247L, 152L, 98L, 482L, 111L,? 257L, 155L, 47L, 10L, 468L, 270L, 313L, 86L, 293L, 160L, 168L,? 409L, 170L, 84L, 180L, 76L, 99L, 214L, 15L, 414L, 394L, 450L,? 4L, 61L, 339L, 342L, 1L, 470L, 210L, 37L, 345L, 115L, 141L, 302L,? 178L, 445L, 6L, 466L, 285L, 174L, 201L, 114L, 369L, 390L, 69L,? 420L, 464L, 269L, 455L, 382L, 25L, 123L, 95L, 230L, 72L, 250L,? 473L, 8L, 274L, 238L, 62L, 461L, 104L, 125L, 128L, 227L, 292L,? 430L, 206L, 360L, 491L, 191L, 142L, 181L, 318L, 484L, 145L, 89L,? 233L, 368L, 412L, 335L, 215L, 146L, 139L, 426L, 375L, 66L, 299L,? 438L, 223L, 175L, 92L, 225L, 276L, 185L, 336L, 371L, 306L, 366L,? 319L), .Dim = c(124L, 8L)) Eliza --> Date: Wed, 27 Feb 2013 05:44:55 -0800 > From: smartpink111 at yahoo.com > Subject: Re: matrix multiplication > To: eliza_botto at hotmail.com > > Hi Elisa, > > Could you just dput that dataset? > Arun > > > > > > > ________________________________ > From: eliza botto <eliza_botto at hotmail.com> > To: "smartpink111 at yahoo.com" <smartpink111 at yahoo.com> > Sent: Wednesday, February 27, 2013 8:38 AM > Subject: matrix multiplication > > > > Dear Arun, > I want to make a distance matrix of the following matrix? > > > ? ? ? ? ?[,1] [,2] ?[,3] [,4] ?[,5] ?[,6] [,7] ?[,8] > ? [1,] ? ?7 ?495 ?106 ?178 ? 39 ?390 ?429 ?14 > ? [2,] ?127 ?457 ? 95 ?193 ?274 ?379 ?468 ? 40 > ? [3,] ?470 ? 30 ? ?1 ?362 ?499 ?478 ?425 ?357 > ? [4,] ?288 ?111 ?463 ?287 ? 85 ?387 ?389 ? 15 > ? [5,] ?416 ?225 ?360 ?317 ? ?7 ?495 ?106 ?178 > ? [6,] ?297 ?438 ?253 ?146 ?127 ?457 ? 95 ?193 > ? [7,] ?323 ? 42 ?234 ? 97 ?470 ? 30 ? ?1 ?362 > ? [8,] ?130 ?352 ?181 ?168 ?288 ?111 ?463 ?287 > ? [9,] ? 53 ?218 ?266 ?133 ?416 ?225 ?360 ?317 > ?[10,] ?232 ?469 ?396 ? ?5 ?297 ?438 ?253 ?146 > ?[11,] ?161 ? 25 ?445 ? 76 ?323 ? 42 ?234 ? 97 > ?[12,] ?169 ?284 ? 99 ?399 ?130 ?352 ?181 ?168 > ?[13,] ? 60 ? 59 ?135 ? ?9 ? 53 ?218 ?266 ?133 > ?[14,] ?415 ? 16 ? 36 ?213 ?232 ?469 ?396 ? ?5 > ?[15,] ? 22 ?249 ? 82 ?334 ?161 ? 25 ?445 ? 76 > ?[16,] ?455 ?395 ? 41 ?192 ?169 ?284 ? 99 ?399 > ?[17,] ?431 ?400 ?302 ?461 ? 60 ? 59 ?135 ? ?9 > ?[18,] ?139 ?175 ? 28 ?283 ?415 ? 16 ? 36 ?213 > ?[19,] ?316 ?327 ?486 ?180 ? 22 ?249 ? 82 ?334 > ?[20,] ? 77 ?339 ?410 ?173 ?455 ?395 ? 41 ?192 > ?[21,] ?260 ?293 ?100 ?147 ?431 ?400 ?302 ?461 > ?[22,] ?418 ?109 ?476 ? 87 ?139 ?175 ? 28 ?283 > ?[23,] ?254 ?426 ?443 ? 98 ?316 ?327 ?486 ?180 > ?[24,] ?377 ?149 ?314 ?198 ? 77 ?339 ?410 ?173 > ?[25,] ?318 ?485 ?203 ?394 ?260 ?293 ?100 ?147 > ?[26,] ?313 ? 51 ?289 ?296 ?418 ?109 ?476 ? 87 > ?[27,] ?371 ?247 ?348 ? 80 ?254 ?426 ?443 ? 98 > ?[28,] ?256 ? 96 ?132 ?208 ?377 ?149 ?314 ?198 > ?[29,] ?204 ?330 ?226 ?430 ?318 ?485 ?203 ?394 > ?[30,] ?300 ?164 ?325 ?148 ?313 ? 51 ?289 ?296 > ?[31,] ?105 ?153 ?241 ?454 ?371 ?247 ?348 ? 80 > ?[32,] ?107 ?267 ?294 ?424 ?256 ? 96 ?132 ?208 > ?[33,] ? 34 ? 63 ?282 ?156 ?204 ?330 ?226 ?430 > ?[34,] ? 73 ?321 ?482 ?483 ?300 ?164 ?325 ?148 > ?[35,] ?401 ?272 ? 44 ?137 ?105 ?153 ?241 ?454 > ?[36,] ?484 ?310 ?141 ?221 ?107 ?267 ?294 ?424 > ?[37,] ? 33 ?258 ?382 ? 72 ? 34 ? 63 ?282 ?156 > ?[38,] ?176 ?167 ?388 ? 78 ? 73 ?321 ?482 ?483 > ?[39,] ? 70 ?177 ?350 ?271 ?401 ?272 ? 44 ?137 > ?[40,] ?479 ?201 ?345 ? 19 ?484 ?310 ?141 ?221 > ?[41,] ? ?4 ?423 ?343 ?437 ? 33 ?258 ?382 ? 72 > ?[42,] ?187 ?493 ?337 ?233 ?176 ?167 ?388 ? 78 > ?[43,] ?473 ?481 ?406 ?422 ? 70 ?177 ?350 ?271 > ?[44,] ?413 ?368 ?500 ?448 ?479 ?201 ?345 ? 19 > ?[45,] ?419 ?138 ?252 ?378 ? ?4 ?423 ?343 ?437 > ?[46,] ?227 ? ?3 ?471 ?235 ?187 ?493 ?337 ?233 > ?[47,] ?374 ?311 ?136 ?110 ?473 ?481 ?406 ?422 > ?[48,] ?381 ? 46 ? 89 ?480 ?413 ?368 ?500 ?448 > ?[49,] ?336 ?402 ?268 ?144 ?419 ?138 ?252 ?378 > ?[50,] ?290 ?199 ?491 ?414 ?227 ? ?3 ?471 ?235 > ?[51,] ? 48 ?351 ? 81 ?155 ?374 ?311 ?136 ?110 > ?[52,] ?251 ?189 ?280 ?326 ?381 ? 46 ? 89 ?480 > ?[53,] ?117 ?102 ?179 ?185 ?336 ?402 ?268 ?144 > ?[54,] ?465 ?160 ?475 ?496 ?290 ?199 ?491 ?414 > ?[55,] ?122 ?142 ?188 ?384 ? 48 ?351 ? 81 ?155 > ?[56,] ?279 ?223 ?407 ?222 ?251 ?189 ?280 ?326 > ?[57,] ?134 ?112 ?435 ? 21 ?117 ?102 ?179 ?185 > ?[58,] ?219 ? 54 ?207 ?281 ?465 ?160 ?475 ?496 > ?[59,] ?404 ?492 ?157 ?125 ?122 ?142 ?188 ?384 > ?[60,] ?285 ? 68 ?441 ? 57 ?279 ?223 ?407 ?222 > ?[61,] ?151 ?244 ?131 ?108 ?134 ?112 ?435 ? 21 > ?[62,] ?261 ?220 ?216 ? 45 ?219 ? 54 ?207 ?281 > ?[63,] ?145 ? 29 ?488 ?184 ?404 ?492 ?157 ?125 > ?[64,] ? 58 ?129 ? 65 ?276 ?285 ? 68 ?441 ? 57 > ?[65,] ?434 ?444 ?456 ?123 ?151 ?244 ?131 ?108 > ?[66,] ?275 ?217 ?154 ?171 ?261 ?220 ?216 ? 45 > ?[67,] ? 13 ?299 ?428 ?346 ?145 ? 29 ?488 ?184 > ?[68,] ?165 ?451 ? 86 ? 50 ? 58 ?129 ? 65 ?276 > ?[69,] ?237 ?319 ?442 ?427 ?434 ?444 ?456 ?123 > ?[70,] ?242 ?191 ?453 ?230 ?275 ?217 ?154 ?171 > ?[71,] ?159 ?197 ?344 ?432 ? 13 ?299 ?428 ?346 > ?[72,] ?206 ?115 ?375 ?329 ?165 ?451 ? 86 ? 50 > ?[73,] ?114 ?259 ?209 ?295 ?237 ?319 ?442 ?427 > ?[74,] ?248 ?380 ?172 ? 12 ?242 ?191 ?453 ?230 > ?[75,] ?408 ?472 ?273 ?477 ?159 ?197 ?344 ?432 > ?[76,] ?367 ?162 ?190 ?240 ?206 ?115 ?375 ?329 > ?[77,] ?307 ? 66 ?450 ?250 ?114 ?259 ?209 ?295 > ?[78,] ?331 ? 31 ?163 ?166 ?248 ?380 ?172 ? 12 > ?[79,] ?376 ?464 ? 75 ? 93 ?408 ?472 ?273 ?477 > ?[80,] ?194 ?366 ? 35 ?359 ?367 ?162 ?190 ?240 > ?[81,] ?210 ? ?8 ? 20 ?364 ?307 ? 66 ?450 ?250 > ?[82,] ?436 ?391 ?320 ?354 ?331 ? 31 ?163 ?166 > ?[83,] ?324 ? 90 ?186 ?239 ?376 ?464 ? 75 ? 93 > ?[84,] ?212 ?196 ?128 ? 47 ?194 ?366 ? 35 ?359 > ?[85,] ? 32 ?298 ?292 ?202 ?210 ? ?8 ? 20 ?364 > ?[86,] ? 43 ?182 ?245 ?466 ?436 ?391 ?320 ?354 > ?[87,] ?278 ? 37 ?265 ?412 ?324 ? 90 ?186 ?239 > ?[88,] ?101 ? 88 ? 79 ?205 ?212 ?196 ?128 ? 47 > ?[89,] ?308 ?439 ? 62 ?312 ? 32 ?298 ?292 ?202 > ?[90,] ? ?6 ? 10 ? 94 ?301 ? 43 ?182 ?245 ?466 > ?[91,] ?361 ?347 ?392 ? 71 ?278 ? 37 ?265 ?412 > ?[92,] ?497 ?467 ? 11 ?386 ?101 ? 88 ? 79 ?205 > ?[93,] ?270 ?309 ?116 ?452 ?308 ?439 ? 62 ?312 > ?[94,] ?152 ?341 ? 24 ?315 ? ?6 ? 10 ? 94 ?301 > ?[95,] ?421 ?229 ?458 ?291 ?361 ?347 ?392 ? 71 > ?[96,] ? 92 ?269 ?356 ?393 ?497 ?467 ? 11 ?386 > ?[97,] ? 18 ?277 ? 84 ?487 ?270 ?309 ?116 ?452 > ?[98,] ?349 ?370 ?397 ?494 ?152 ?341 ? 24 ?315 > ?[99,] ? 27 ?446 ?103 ?417 ?421 ?229 ?458 ?291 > [100,] ? 69 ?383 ?409 ?246 ? 92 ?269 ?356 ?393 > [101,] ? ?2 ?328 ?385 ?353 ? 18 ?277 ? 84 ?487 > [102,] ?474 ?255 ?403 ? 52 ?349 ?370 ?397 ?494 > [103,] ? 38 ?140 ? 61 ?257 ? 27 ?446 ?103 ?417 > [104,] ?263 ?373 ?332 ?215 ? 69 ?383 ?409 ?246 > [105,] ? 91 ? 17 ?333 ?143 ? ?2 ?328 ?385 ?353 > [106,] ?460 ?358 ?224 ? 23 ?474 ?255 ?403 ? 52 > [107,] ?398 ?433 ?369 ?121 ? 38 ?140 ? 61 ?257 > [108,] ?303 ?120 ?365 ?113 ?263 ?373 ?332 ?215 > [109,] ?411 ?231 ?286 ?174 ? 91 ? 17 ?333 ?143 > [110,] ?158 ?200 ?449 ?211 ?460 ?358 ?224 ? 23 > [111,] ?306 ? 56 ? 74 ?338 ?398 ?433 ?369 ?121 > [112,] ?498 ?150 ?236 ?440 ?303 ?120 ?365 ?113 > [113,] ?104 ?243 ?170 ?304 ?411 ?231 ?286 ?174 > [114,] ?183 ?489 ? 49 ? 55 ?158 ?200 ?449 ?211 > [115,] ?195 ?355 ?363 ?322 ?306 ? 56 ? 74 ?338 > [116,] ? 64 ?335 ?228 ?342 ?498 ?150 ?236 ?440 > [117,] ?305 ?214 ?262 ?405 ?104 ?243 ?170 ?304 > [118,] ?447 ?124 ?340 ?118 ?183 ?489 ? 49 ? 55 > [119,] ?238 ?126 ?264 ? 67 ?195 ?355 ?363 ?322 > [120,] ?119 ?372 ?490 ? 26 ? 64 ?335 ?228 ?342 > [121,] ?390 ?429 ? 14 ?420 ?305 ?214 ?262 ?405 > [122,] ?379 ?468 ? 40 ?459 ?447 ?124 ?340 ?118 > [123,] ?478 ?425 ?357 ? 83 ?238 ?126 ?264 ? 67 > [124,] ?387 ?389 ? 15 ?462 ?119 ?372 ?490 ? 26 > > i want to have a distance matrix generated on the following procedure > > >Subtraction should take place row-wise > > > > Subtraction of second row from first row > ========================> ={abs[(1,1)-(2,1)]*abs[(1,5)-(2,5)]}+{abs[(1,2)-(2,2)]*abs[(1,6)-(2,6)]}+{abs[(1,3)-(2,3)]*abs[(1,7)-(2,7)]}+{abs[(1,4)-(2,4)]*abs[(1,8)-(2,8)]} > where in (1,1) first coordinate figure is row number and second is column number > so ?if we put the values in above line, we should get > ={abs[(7)-(127)]*abs[(39)-(274)]}+{abs[(495)-(457)]*abs[(390)-(379)]}+{abs[(106)-(95)]*abs[(429)-(468)]}+{abs[(178)-(193)]*abs[(14)-(40)]} > =29437 > Subtraction of third row from first row > ========================> ={abs[(1,1)-(3,1)]*abs[(1,5)-(3,5)]}+{abs[(1,2)-(3,2)]*abs[(1,6)-(3,6)]}+{abs[(1,3)-(3,3)]*abs[(1,7)-(3,7)]}+{abs[(1,4)-(3,4)]*abs[(1,8)-(3,8)]} > > when all the rows are subtracted from from 1. then all the rows should be subtracted from row 2 and then from row 3 and so on.... till 124th row. So, what i want to have in the end is a distance matrix with same upper and lower triangle and 0's on diagonal. > > Thankyou so very much in advance > > ELIZA
Hi, Just to add: res<-do.call(cbind,lapply(seq_len(nrow(mat1)),function(i) {new1<-do.call(rbind,lapply(seq_len(nrow(mat1[-i,])),function(j) {x1<-rbind(mat1[i,],mat1[j,]); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2,3])*abs(x1[1,7]-x1[2,7]))+(abs(x1[1,4]-x1[2,4])*abs(x1[1,8]-x1[2,8]))}));new1})) res3<-rbind(res,c(res[,124],0)) #If I do this on a smaller dataset: ?mat2<-head(mat1) ?mat2 #???? [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] #[1,]? 428? 401?? 63? 436? 132? 400? 403? 164 #[2,]? 359? 476? 424? 469? 343?? 78? 296?? 91 #[3,]? 353? 262? 496? 186? 447? 273? 268? 351 #[4,]? 498? 159? 126? 472? 457? 411? 489? 443 #[5,]? 169? 195? 334? 297? 428? 401?? 63? 436 #[6,]?? 46? 102? 183?? 50? 359? 476? 424? 469 res2<-do.call(cbind,lapply(seq_len(nrow(mat2)),function(i) {new1<-do.call(rbind,lapply(seq_len(nrow(mat2[-i,])),function(j) {x1<-rbind(mat2[i,],mat2[j,]); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2,3])*abs(x1[1,7]-x1[2,7]))+(abs(x1[1,4]-x1[2,4])*abs(x1[1,8]-x1[2,8]))}));new1})) ?resTrial<-rbind(res2,c(res2[,6],0)) resTrial #?????? [,1]?? [,2]?? [,3]?? [,4]?? [,5]?? [,6] #[1,]????? 0? 79745 146483? 40874 206818 229688 #[2,]? 79745????? 0 117950 179977 187223 343090 #[3,] 146483 117950????? 0 123746? 54717 124372 #[4,]? 40874 179977 123746????? 0? 99734? 62678 #[5,] 206818 187223? 54717? 99734????? 0? 78124 #[6,] 229688 343090 124372? 62678? 78124????? 0 A.K. ________________________________ From: eliza botto <eliza_botto at hotmail.com> To: "smartpink111 at yahoo.com" <smartpink111 at yahoo.com> Sent: Wednesday, February 27, 2013 8:47 AM Subject: RE: matrix multiplication there you go>dput(eliza)structure(c(428L, 359L, 353L, 498L, 169L, 46L, 29L, 444L, 194L,? 439L, 284L, 79L, 226L, 105L, 106L, 326L, 234L, 196L, 417L, 190L,? 480L, 275L, 478L, 341L, 197L, 395L, 85L, 295L, 70L, 18L, 471L,? 218L, 19L, 43L, 280L, 427L, 229L, 5L, 205L, 494L, 393L, 307L,? 465L, 383L, 265L, 103L, 348L, 166L, 58L, 320L, 14L, 107L, 440L,? 24L, 347L, 419L, 135L, 202L, 294L, 173L, 121L, 358L, 51L, 231L,? 118L, 109L, 182L, 219L, 42L, 73L, 435L, 389L, 431L, 81L, 149L,? 388L, 415L, 256L, 312L, 446L, 45L, 162L, 485L, 154L, 55L, 153L,? 137L, 290L, 93L, 40L, 110L, 167L, 315L, 266L, 317L, 314L, 264L,? 277L, 488L, 28L, 354L, 303L, 490L, 192L, 432L, 228L, 222L, 418L,? 323L, 244L, 239L, 193L, 120L, 116L, 148L, 57L, 246L, 300L, 143L,? 208L, 400L, 78L, 273L, 411L, 401L, 476L, 262L, 159L, 195L, 102L,? 75L, 136L, 402L, 32L, 199L, 286L, 477L, 54L, 429L, 80L, 316L,? 30L, 333L, 387L, 452L, 324L, 456L, 39L, 138L, 113L, 448L, 377L,? 122L, 441L, 396L, 454L, 497L, 161L, 21L, 117L, 413L, 94L, 459L,? 156L, 365L, 322L, 397L, 88L, 207L, 150L, 209L, 184L, 378L, 217L,? 176L, 52L, 374L, 189L, 97L, 340L, 357L, 157L, 220L, 74L, 356L,? 495L, 453L, 26L, 499L, 364L, 267L, 331L, 245L, 258L, 242L, 381L,? 36L, 16L, 328L, 131L, 255L, 363L, 298L, 373L, 416L, 200L, 56L,? 263L, 288L, 13L, 305L, 291L, 17L, 53L, 130L, 458L, 385L, 198L,? 158L, 140L, 492L, 249L, 27L, 134L, 479L, 171L, 177L, 9L, 355L,? 398L, 380L, 404L, 304L, 129L, 338L, 281L, 65L, 386L, 144L, 252L,? 77L, 352L, 20L, 96L, 403L, 296L, 268L, 489L, 63L, 424L, 496L,? 126L, 334L, 183L, 232L, 406L, 407L, 163L, 346L, 287L, 475L, 127L,? 321L, 124L, 237L, 308L, 376L, 212L, 423L, 211L, 329L, 437L, 179L,? 253L, 372L, 101L, 251L, 90L, 433L, 311L, 241L, 327L, 422L, 349L,? 493L, 442L, 38L, 449L, 410L, 370L, 421L, 325L, 451L, 240L, 71L,? 392L, 2L, 151L, 332L, 83L, 350L, 87L, 361L, 330L, 279L, 362L,? 310L, 487L, 278L, 367L, 248L, 462L, 59L, 213L, 68L, 112L, 60L,? 481L, 165L, 235L, 22L, 434L, 272L, 460L, 309L, 301L, 500L, 282L,? 82L, 100L, 261L, 34L, 188L, 133L, 344L, 7L, 486L, 67L, 399L,? 254L, 41L, 483L, 64L, 405L, 108L, 236L, 384L, 467L, 49L, 283L,? 119L, 463L, 147L, 379L, 216L, 474L, 204L, 48L, 260L, 12L, 337L,? 187L, 271L, 31L, 289L, 172L, 35L, 408L, 164L, 91L, 351L, 443L,? 436L, 469L, 186L, 472L, 297L, 50L, 425L, 224L, 3L, 221L, 11L,? 391L, 33L, 243L, 247L, 152L, 98L, 482L, 111L, 257L, 155L, 47L,? 10L, 468L, 270L, 313L, 86L, 293L, 160L, 168L, 409L, 170L, 84L,? 180L, 76L, 99L, 214L, 15L, 414L, 394L, 450L, 4L, 61L, 339L, 342L,? 1L, 470L, 210L, 37L, 345L, 115L, 141L, 302L, 178L, 445L, 6L,? 466L, 285L, 174L, 201L, 114L, 369L, 390L, 69L, 420L, 464L, 269L,? 455L, 382L, 25L, 123L, 95L, 230L, 72L, 250L, 473L, 8L, 274L,? 238L, 62L, 461L, 104L, 125L, 128L, 227L, 292L, 430L, 206L, 360L,? 491L, 191L, 142L, 181L, 318L, 484L, 145L, 89L, 233L, 368L, 412L,? 335L, 215L, 146L, 139L, 426L, 375L, 66L, 299L, 438L, 223L, 175L,? 92L, 225L, 276L, 185L, 336L, 371L, 306L, 366L, 319L, 203L, 44L,? 259L, 23L, 132L, 343L, 447L, 457L, 428L, 359L, 353L, 498L, 169L,? 46L, 29L, 444L, 194L, 439L, 284L, 79L, 226L, 105L, 106L, 326L,? 234L, 196L, 417L, 190L, 480L, 275L, 478L, 341L, 197L, 395L, 85L,? 295L, 70L, 18L, 471L, 218L, 19L, 43L, 280L, 427L, 229L, 5L, 205L,? 494L, 393L, 307L, 465L, 383L, 265L, 103L, 348L, 166L, 58L, 320L,? 14L, 107L, 440L, 24L, 347L, 419L, 135L, 202L, 294L, 173L, 121L,? 358L, 51L, 231L, 118L, 109L, 182L, 219L, 42L, 73L, 435L, 389L,? 431L, 81L, 149L, 388L, 415L, 256L, 312L, 446L, 45L, 162L, 485L,? 154L, 55L, 153L, 137L, 290L, 93L, 40L, 110L, 167L, 315L, 266L,? 317L, 314L, 264L, 277L, 488L, 28L, 354L, 303L, 490L, 192L, 432L,? 228L, 222L, 418L, 323L, 244L, 239L, 193L, 120L, 116L, 148L, 57L,? 246L, 300L, 143L, 208L, 400L, 78L, 273L, 411L, 401L, 476L, 262L,? 159L, 195L, 102L, 75L, 136L, 402L, 32L, 199L, 286L, 477L, 54L,? 429L, 80L, 316L, 30L, 333L, 387L, 452L, 324L, 456L, 39L, 138L,? 113L, 448L, 377L, 122L, 441L, 396L, 454L, 497L, 161L, 21L, 117L,? 413L, 94L, 459L, 156L, 365L, 322L, 397L, 88L, 207L, 150L, 209L,? 184L, 378L, 217L, 176L, 52L, 374L, 189L, 97L, 340L, 357L, 157L,? 220L, 74L, 356L, 495L, 453L, 26L, 499L, 364L, 267L, 331L, 245L,? 258L, 242L, 381L, 36L, 16L, 328L, 131L, 255L, 363L, 298L, 373L,? 416L, 200L, 56L, 263L, 288L, 13L, 305L, 291L, 17L, 53L, 130L,? 458L, 385L, 198L, 158L, 140L, 492L, 249L, 27L, 134L, 479L, 171L,? 177L, 9L, 355L, 398L, 380L, 404L, 304L, 129L, 338L, 281L, 65L,? 386L, 144L, 252L, 77L, 352L, 20L, 96L, 403L, 296L, 268L, 489L,? 63L, 424L, 496L, 126L, 334L, 183L, 232L, 406L, 407L, 163L, 346L,? 287L, 475L, 127L, 321L, 124L, 237L, 308L, 376L, 212L, 423L, 211L,? 329L, 437L, 179L, 253L, 372L, 101L, 251L, 90L, 433L, 311L, 241L,? 327L, 422L, 349L, 493L, 442L, 38L, 449L, 410L, 370L, 421L, 325L,? 451L, 240L, 71L, 392L, 2L, 151L, 332L, 83L, 350L, 87L, 361L,? 330L, 279L, 362L, 310L, 487L, 278L, 367L, 248L, 462L, 59L, 213L,? 68L, 112L, 60L, 481L, 165L, 235L, 22L, 434L, 272L, 460L, 309L,? 301L, 500L, 282L, 82L, 100L, 261L, 34L, 188L, 133L, 344L, 7L,? 486L, 67L, 399L, 254L, 41L, 483L, 64L, 405L, 108L, 236L, 384L,? 467L, 49L, 283L, 119L, 463L, 147L, 379L, 216L, 474L, 204L, 48L,? 260L, 12L, 337L, 187L, 271L, 31L, 289L, 172L, 35L, 408L, 164L,? 91L, 351L, 443L, 436L, 469L, 186L, 472L, 297L, 50L, 425L, 224L,? 3L, 221L, 11L, 391L, 33L, 243L, 247L, 152L, 98L, 482L, 111L,? 257L, 155L, 47L, 10L, 468L, 270L, 313L, 86L, 293L, 160L, 168L,? 409L, 170L, 84L, 180L, 76L, 99L, 214L, 15L, 414L, 394L, 450L,? 4L, 61L, 339L, 342L, 1L, 470L, 210L, 37L, 345L, 115L, 141L, 302L,? 178L, 445L, 6L, 466L, 285L, 174L, 201L, 114L, 369L, 390L, 69L,? 420L, 464L, 269L, 455L, 382L, 25L, 123L, 95L, 230L, 72L, 250L,? 473L, 8L, 274L, 238L, 62L, 461L, 104L, 125L, 128L, 227L, 292L,? 430L, 206L, 360L, 491L, 191L, 142L, 181L, 318L, 484L, 145L, 89L,? 233L, 368L, 412L, 335L, 215L, 146L, 139L, 426L, 375L, 66L, 299L,? 438L, 223L, 175L, 92L, 225L, 276L, 185L, 336L, 371L, 306L, 366L,? 319L), .Dim = c(124L, 8L)) Eliza --> Date: Wed, 27 Feb 2013 05:44:55 -0800 > From: smartpink111 at yahoo.com > Subject: Re: matrix multiplication > To: eliza_botto at hotmail.com > > Hi Elisa, > > Could you just dput that dataset? > Arun > > > > > > > ________________________________ > From: eliza botto <eliza_botto at hotmail.com> > To: "smartpink111 at yahoo.com" <smartpink111 at yahoo.com> > Sent: Wednesday, February 27, 2013 8:38 AM > Subject: matrix multiplication > > > > Dear Arun, > I want to make a distance matrix of the following matrix? > > > ? ? ? ? ?[,1] [,2] ?[,3] [,4] ?[,5] ?[,6] [,7] ?[,8] > ? [1,] ? ?7 ?495 ?106 ?178 ? 39 ?390 ?429 ?14 > ? [2,] ?127 ?457 ? 95 ?193 ?274 ?379 ?468 ? 40 > ? [3,] ?470 ? 30 ? ?1 ?362 ?499 ?478 ?425 ?357 > ? [4,] ?288 ?111 ?463 ?287 ? 85 ?387 ?389 ? 15 > ? [5,] ?416 ?225 ?360 ?317 ? ?7 ?495 ?106 ?178 > ? [6,] ?297 ?438 ?253 ?146 ?127 ?457 ? 95 ?193 > ? [7,] ?323 ? 42 ?234 ? 97 ?470 ? 30 ? ?1 ?362 > ? [8,] ?130 ?352 ?181 ?168 ?288 ?111 ?463 ?287 > ? [9,] ? 53 ?218 ?266 ?133 ?416 ?225 ?360 ?317 > ?[10,] ?232 ?469 ?396 ? ?5 ?297 ?438 ?253 ?146 > ?[11,] ?161 ? 25 ?445 ? 76 ?323 ? 42 ?234 ? 97 > ?[12,] ?169 ?284 ? 99 ?399 ?130 ?352 ?181 ?168 > ?[13,] ? 60 ? 59 ?135 ? ?9 ? 53 ?218 ?266 ?133 > ?[14,] ?415 ? 16 ? 36 ?213 ?232 ?469 ?396 ? ?5 > ?[15,] ? 22 ?249 ? 82 ?334 ?161 ? 25 ?445 ? 76 > ?[16,] ?455 ?395 ? 41 ?192 ?169 ?284 ? 99 ?399 > ?[17,] ?431 ?400 ?302 ?461 ? 60 ? 59 ?135 ? ?9 > ?[18,] ?139 ?175 ? 28 ?283 ?415 ? 16 ? 36 ?213 > ?[19,] ?316 ?327 ?486 ?180 ? 22 ?249 ? 82 ?334 > ?[20,] ? 77 ?339 ?410 ?173 ?455 ?395 ? 41 ?192 > ?[21,] ?260 ?293 ?100 ?147 ?431 ?400 ?302 ?461 > ?[22,] ?418 ?109 ?476 ? 87 ?139 ?175 ? 28 ?283 > ?[23,] ?254 ?426 ?443 ? 98 ?316 ?327 ?486 ?180 > ?[24,] ?377 ?149 ?314 ?198 ? 77 ?339 ?410 ?173 > ?[25,] ?318 ?485 ?203 ?394 ?260 ?293 ?100 ?147 > ?[26,] ?313 ? 51 ?289 ?296 ?418 ?109 ?476 ? 87 > ?[27,] ?371 ?247 ?348 ? 80 ?254 ?426 ?443 ? 98 > ?[28,] ?256 ? 96 ?132 ?208 ?377 ?149 ?314 ?198 > ?[29,] ?204 ?330 ?226 ?430 ?318 ?485 ?203 ?394 > ?[30,] ?300 ?164 ?325 ?148 ?313 ? 51 ?289 ?296 > ?[31,] ?105 ?153 ?241 ?454 ?371 ?247 ?348 ? 80 > ?[32,] ?107 ?267 ?294 ?424 ?256 ? 96 ?132 ?208 > ?[33,] ? 34 ? 63 ?282 ?156 ?204 ?330 ?226 ?430 > ?[34,] ? 73 ?321 ?482 ?483 ?300 ?164 ?325 ?148 > ?[35,] ?401 ?272 ? 44 ?137 ?105 ?153 ?241 ?454 > ?[36,] ?484 ?310 ?141 ?221 ?107 ?267 ?294 ?424 > ?[37,] ? 33 ?258 ?382 ? 72 ? 34 ? 63 ?282 ?156 > ?[38,] ?176 ?167 ?388 ? 78 ? 73 ?321 ?482 ?483 > ?[39,] ? 70 ?177 ?350 ?271 ?401 ?272 ? 44 ?137 > ?[40,] ?479 ?201 ?345 ? 19 ?484 ?310 ?141 ?221 > ?[41,] ? ?4 ?423 ?343 ?437 ? 33 ?258 ?382 ? 72 > ?[42,] ?187 ?493 ?337 ?233 ?176 ?167 ?388 ? 78 > ?[43,] ?473 ?481 ?406 ?422 ? 70 ?177 ?350 ?271 > ?[44,] ?413 ?368 ?500 ?448 ?479 ?201 ?345 ? 19 > ?[45,] ?419 ?138 ?252 ?378 ? ?4 ?423 ?343 ?437 > ?[46,] ?227 ? ?3 ?471 ?235 ?187 ?493 ?337 ?233 > ?[47,] ?374 ?311 ?136 ?110 ?473 ?481 ?406 ?422 > ?[48,] ?381 ? 46 ? 89 ?480 ?413 ?368 ?500 ?448 > ?[49,] ?336 ?402 ?268 ?144 ?419 ?138 ?252 ?378 > ?[50,] ?290 ?199 ?491 ?414 ?227 ? ?3 ?471 ?235 > ?[51,] ? 48 ?351 ? 81 ?155 ?374 ?311 ?136 ?110 > ?[52,] ?251 ?189 ?280 ?326 ?381 ? 46 ? 89 ?480 > ?[53,] ?117 ?102 ?179 ?185 ?336 ?402 ?268 ?144 > ?[54,] ?465 ?160 ?475 ?496 ?290 ?199 ?491 ?414 > ?[55,] ?122 ?142 ?188 ?384 ? 48 ?351 ? 81 ?155 > ?[56,] ?279 ?223 ?407 ?222 ?251 ?189 ?280 ?326 > ?[57,] ?134 ?112 ?435 ? 21 ?117 ?102 ?179 ?185 > ?[58,] ?219 ? 54 ?207 ?281 ?465 ?160 ?475 ?496 > ?[59,] ?404 ?492 ?157 ?125 ?122 ?142 ?188 ?384 > ?[60,] ?285 ? 68 ?441 ? 57 ?279 ?223 ?407 ?222 > ?[61,] ?151 ?244 ?131 ?108 ?134 ?112 ?435 ? 21 > ?[62,] ?261 ?220 ?216 ? 45 ?219 ? 54 ?207 ?281 > ?[63,] ?145 ? 29 ?488 ?184 ?404 ?492 ?157 ?125 > ?[64,] ? 58 ?129 ? 65 ?276 ?285 ? 68 ?441 ? 57 > ?[65,] ?434 ?444 ?456 ?123 ?151 ?244 ?131 ?108 > ?[66,] ?275 ?217 ?154 ?171 ?261 ?220 ?216 ? 45 > ?[67,] ? 13 ?299 ?428 ?346 ?145 ? 29 ?488 ?184 > ?[68,] ?165 ?451 ? 86 ? 50 ? 58 ?129 ? 65 ?276 > ?[69,] ?237 ?319 ?442 ?427 ?434 ?444 ?456 ?123 > ?[70,] ?242 ?191 ?453 ?230 ?275 ?217 ?154 ?171 > ?[71,] ?159 ?197 ?344 ?432 ? 13 ?299 ?428 ?346 > ?[72,] ?206 ?115 ?375 ?329 ?165 ?451 ? 86 ? 50 > ?[73,] ?114 ?259 ?209 ?295 ?237 ?319 ?442 ?427 > ?[74,] ?248 ?380 ?172 ? 12 ?242 ?191 ?453 ?230 > ?[75,] ?408 ?472 ?273 ?477 ?159 ?197 ?344 ?432 > ?[76,] ?367 ?162 ?190 ?240 ?206 ?115 ?375 ?329 > ?[77,] ?307 ? 66 ?450 ?250 ?114 ?259 ?209 ?295 > ?[78,] ?331 ? 31 ?163 ?166 ?248 ?380 ?172 ? 12 > ?[79,] ?376 ?464 ? 75 ? 93 ?408 ?472 ?273 ?477 > ?[80,] ?194 ?366 ? 35 ?359 ?367 ?162 ?190 ?240 > ?[81,] ?210 ? ?8 ? 20 ?364 ?307 ? 66 ?450 ?250 > ?[82,] ?436 ?391 ?320 ?354 ?331 ? 31 ?163 ?166 > ?[83,] ?324 ? 90 ?186 ?239 ?376 ?464 ? 75 ? 93 > ?[84,] ?212 ?196 ?128 ? 47 ?194 ?366 ? 35 ?359 > ?[85,] ? 32 ?298 ?292 ?202 ?210 ? ?8 ? 20 ?364 > ?[86,] ? 43 ?182 ?245 ?466 ?436 ?391 ?320 ?354 > ?[87,] ?278 ? 37 ?265 ?412 ?324 ? 90 ?186 ?239 > ?[88,] ?101 ? 88 ? 79 ?205 ?212 ?196 ?128 ? 47 > ?[89,] ?308 ?439 ? 62 ?312 ? 32 ?298 ?292 ?202 > ?[90,] ? ?6 ? 10 ? 94 ?301 ? 43 ?182 ?245 ?466 > ?[91,] ?361 ?347 ?392 ? 71 ?278 ? 37 ?265 ?412 > ?[92,] ?497 ?467 ? 11 ?386 ?101 ? 88 ? 79 ?205 > ?[93,] ?270 ?309 ?116 ?452 ?308 ?439 ? 62 ?312 > ?[94,] ?152 ?341 ? 24 ?315 ? ?6 ? 10 ? 94 ?301 > ?[95,] ?421 ?229 ?458 ?291 ?361 ?347 ?392 ? 71 > ?[96,] ? 92 ?269 ?356 ?393 ?497 ?467 ? 11 ?386 > ?[97,] ? 18 ?277 ? 84 ?487 ?270 ?309 ?116 ?452 > ?[98,] ?349 ?370 ?397 ?494 ?152 ?341 ? 24 ?315 > ?[99,] ? 27 ?446 ?103 ?417 ?421 ?229 ?458 ?291 > [100,] ? 69 ?383 ?409 ?246 ? 92 ?269 ?356 ?393 > [101,] ? ?2 ?328 ?385 ?353 ? 18 ?277 ? 84 ?487 > [102,] ?474 ?255 ?403 ? 52 ?349 ?370 ?397 ?494 > [103,] ? 38 ?140 ? 61 ?257 ? 27 ?446 ?103 ?417 > [104,] ?263 ?373 ?332 ?215 ? 69 ?383 ?409 ?246 > [105,] ? 91 ? 17 ?333 ?143 ? ?2 ?328 ?385 ?353 > [106,] ?460 ?358 ?224 ? 23 ?474 ?255 ?403 ? 52 > [107,] ?398 ?433 ?369 ?121 ? 38 ?140 ? 61 ?257 > [108,] ?303 ?120 ?365 ?113 ?263 ?373 ?332 ?215 > [109,] ?411 ?231 ?286 ?174 ? 91 ? 17 ?333 ?143 > [110,] ?158 ?200 ?449 ?211 ?460 ?358 ?224 ? 23 > [111,] ?306 ? 56 ? 74 ?338 ?398 ?433 ?369 ?121 > [112,] ?498 ?150 ?236 ?440 ?303 ?120 ?365 ?113 > [113,] ?104 ?243 ?170 ?304 ?411 ?231 ?286 ?174 > [114,] ?183 ?489 ? 49 ? 55 ?158 ?200 ?449 ?211 > [115,] ?195 ?355 ?363 ?322 ?306 ? 56 ? 74 ?338 > [116,] ? 64 ?335 ?228 ?342 ?498 ?150 ?236 ?440 > [117,] ?305 ?214 ?262 ?405 ?104 ?243 ?170 ?304 > [118,] ?447 ?124 ?340 ?118 ?183 ?489 ? 49 ? 55 > [119,] ?238 ?126 ?264 ? 67 ?195 ?355 ?363 ?322 > [120,] ?119 ?372 ?490 ? 26 ? 64 ?335 ?228 ?342 > [121,] ?390 ?429 ? 14 ?420 ?305 ?214 ?262 ?405 > [122,] ?379 ?468 ? 40 ?459 ?447 ?124 ?340 ?118 > [123,] ?478 ?425 ?357 ? 83 ?238 ?126 ?264 ? 67 > [124,] ?387 ?389 ? 15 ?462 ?119 ?372 ?490 ? 26 > > i want to have a distance matrix generated on the following procedure > > >Subtraction should take place row-wise > > > > Subtraction of second row from first row > ========================> ={abs[(1,1)-(2,1)]*abs[(1,5)-(2,5)]}+{abs[(1,2)-(2,2)]*abs[(1,6)-(2,6)]}+{abs[(1,3)-(2,3)]*abs[(1,7)-(2,7)]}+{abs[(1,4)-(2,4)]*abs[(1,8)-(2,8)]} > where in (1,1) first coordinate figure is row number and second is column number > so ?if we put the values in above line, we should get > ={abs[(7)-(127)]*abs[(39)-(274)]}+{abs[(495)-(457)]*abs[(390)-(379)]}+{abs[(106)-(95)]*abs[(429)-(468)]}+{abs[(178)-(193)]*abs[(14)-(40)]} > =29437 > Subtraction of third row from first row > ========================> ={abs[(1,1)-(3,1)]*abs[(1,5)-(3,5)]}+{abs[(1,2)-(3,2)]*abs[(1,6)-(3,6)]}+{abs[(1,3)-(3,3)]*abs[(1,7)-(3,7)]}+{abs[(1,4)-(3,4)]*abs[(1,8)-(3,8)]} > > when all the rows are subtracted from from 1. then all the rows should be subtracted from row 2 and then from row 3 and so on.... till 124th row. So, what i want to have in the end is a distance matrix with same upper and lower triangle and 0's on diagonal. > > Thankyou so very much in advance > > ELIZA
HI Elisa, You can also use: mat2<- head(mat1) resNew<-do.call(cbind,lapply(seq_len(nrow(mat2)),function(i) do.call(rbind,lapply(split(rbind(mat2[i,],mat2[-i,]),1:nrow(rbind(mat2[i,],mat2[-i,]))),function(x) {x1<-rbind(mat2[i,],x); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2,3])*abs(x1[1,7]-x1[2,7]))+(abs(x1[1,4]-x1[2,4])*abs(x1[1,8]-x1[2,8]))})))) resNew1<-do.call(cbind,lapply(seq_len(ncol(resNew)),function(i) c(c(tail(resNew[seq(1,i,1),i],-1),0),resNew[-c(1:i),i]))) ?attr(resNew1,"dimnames")<- NULL ?identical(resNew1,resTrial) #[1] TRUE ?resNew1 #?????? [,1]?? [,2]?? [,3]?? [,4]?? [,5]?? [,6] #[1,]????? 0? 79745 146483? 40874 206818 229688 #[2,]? 79745????? 0 117950 179977 187223 343090 #[3,] 146483 117950????? 0 123746? 54717 124372 #[4,]? 40874 179977 123746????? 0? 99734? 62678 #[5,] 206818 187223? 54717? 99734????? 0? 78124 #[6,] 229688 343090 124372? 62678? 78124????? 0 A.K. ----- Original Message ----- From: arun <smartpink111 at yahoo.com> To: eliza botto <eliza_botto at hotmail.com> Cc: R help <r-help at r-project.org> Sent: Wednesday, February 27, 2013 9:41 AM Subject: Re: matrix multiplication Hi, Just to add: res<-do.call(cbind,lapply(seq_len(nrow(mat1)),function(i) {new1<-do.call(rbind,lapply(seq_len(nrow(mat1[-i,])),function(j) {x1<-rbind(mat1[i,],mat1[j,]); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2,3])*abs(x1[1,7]-x1[2,7]))+(abs(x1[1,4]-x1[2,4])*abs(x1[1,8]-x1[2,8]))}));new1})) res3<-rbind(res,c(res[,124],0)) #If I do this on a smaller dataset: ?mat2<-head(mat1) ?mat2 #???? [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] #[1,]? 428? 401?? 63? 436? 132? 400? 403? 164 #[2,]? 359? 476? 424? 469? 343?? 78? 296?? 91 #[3,]? 353? 262? 496? 186? 447? 273? 268? 351 #[4,]? 498? 159? 126? 472? 457? 411? 489? 443 #[5,]? 169? 195? 334? 297? 428? 401?? 63? 436 #[6,]?? 46? 102? 183?? 50? 359? 476? 424? 469 res2<-do.call(cbind,lapply(seq_len(nrow(mat2)),function(i) {new1<-do.call(rbind,lapply(seq_len(nrow(mat2[-i,])),function(j) {x1<-rbind(mat2[i,],mat2[j,]); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2,3])*abs(x1[1,7]-x1[2,7]))+(abs(x1[1,4]-x1[2,4])*abs(x1[1,8]-x1[2,8]))}));new1})) ?resTrial<-rbind(res2,c(res2[,6],0)) resTrial #?????? [,1]?? [,2]?? [,3]?? [,4]?? [,5]?? [,6] #[1,]????? 0? 79745 146483? 40874 206818 229688 #[2,]? 79745????? 0 117950 179977 187223 343090 #[3,] 146483 117950????? 0 123746? 54717 124372 #[4,]? 40874 179977 123746????? 0? 99734? 62678 #[5,] 206818 187223? 54717? 99734????? 0? 78124 #[6,] 229688 343090 124372? 62678? 78124????? 0 A.K. ________________________________ From: eliza botto <eliza_botto at hotmail.com> To: "smartpink111 at yahoo.com" <smartpink111 at yahoo.com> Sent: Wednesday, February 27, 2013 8:47 AM Subject: RE: matrix multiplication there you go>dput(eliza)structure(c(428L, 359L, 353L, 498L, 169L, 46L, 29L, 444L, 194L,? 439L, 284L, 79L, 226L, 105L, 106L, 326L, 234L, 196L, 417L, 190L,? 480L, 275L, 478L, 341L, 197L, 395L, 85L, 295L, 70L, 18L, 471L,? 218L, 19L, 43L, 280L, 427L, 229L, 5L, 205L, 494L, 393L, 307L,? 465L, 383L, 265L, 103L, 348L, 166L, 58L, 320L, 14L, 107L, 440L,? 24L, 347L, 419L, 135L, 202L, 294L, 173L, 121L, 358L, 51L, 231L,? 118L, 109L, 182L, 219L, 42L, 73L, 435L, 389L, 431L, 81L, 149L,? 388L, 415L, 256L, 312L, 446L, 45L, 162L, 485L, 154L, 55L, 153L,? 137L, 290L, 93L, 40L, 110L, 167L, 315L, 266L, 317L, 314L, 264L,? 277L, 488L, 28L, 354L, 303L, 490L, 192L, 432L, 228L, 222L, 418L,? 323L, 244L, 239L, 193L, 120L, 116L, 148L, 57L, 246L, 300L, 143L,? 208L, 400L, 78L, 273L, 411L, 401L, 476L, 262L, 159L, 195L, 102L,? 75L, 136L, 402L, 32L, 199L, 286L, 477L, 54L, 429L, 80L, 316L,? 30L, 333L, 387L, 452L, 324L, 456L, 39L, 138L, 113L, 448L, 377L,? 122L, 441L, 396L, 454L, 497L, 161L, 21L, 117L, 413L, 94L, 459L,? 156L, 365L, 322L, 397L, 88L, 207L, 150L, 209L, 184L, 378L, 217L,? 176L, 52L, 374L, 189L, 97L, 340L, 357L, 157L, 220L, 74L, 356L,? 495L, 453L, 26L, 499L, 364L, 267L, 331L, 245L, 258L, 242L, 381L,? 36L, 16L, 328L, 131L, 255L, 363L, 298L, 373L, 416L, 200L, 56L,? 263L, 288L, 13L, 305L, 291L, 17L, 53L, 130L, 458L, 385L, 198L,? 158L, 140L, 492L, 249L, 27L, 134L, 479L, 171L, 177L, 9L, 355L,? 398L, 380L, 404L, 304L, 129L, 338L, 281L, 65L, 386L, 144L, 252L,? 77L, 352L, 20L, 96L, 403L, 296L, 268L, 489L, 63L, 424L, 496L,? 126L, 334L, 183L, 232L, 406L, 407L, 163L, 346L, 287L, 475L, 127L,? 321L, 124L, 237L, 308L, 376L, 212L, 423L, 211L, 329L, 437L, 179L,? 253L, 372L, 101L, 251L, 90L, 433L, 311L, 241L, 327L, 422L, 349L,? 493L, 442L, 38L, 449L, 410L, 370L, 421L, 325L, 451L, 240L, 71L,? 392L, 2L, 151L, 332L, 83L, 350L, 87L, 361L, 330L, 279L, 362L,? 310L, 487L, 278L, 367L, 248L, 462L, 59L, 213L, 68L, 112L, 60L,? 481L, 165L, 235L, 22L, 434L, 272L, 460L, 309L, 301L, 500L, 282L,? 82L, 100L, 261L, 34L, 188L, 133L, 344L, 7L, 486L, 67L, 399L,? 254L, 41L, 483L, 64L, 405L, 108L, 236L, 384L, 467L, 49L, 283L,? 119L, 463L, 147L, 379L, 216L, 474L, 204L, 48L, 260L, 12L, 337L,? 187L, 271L, 31L, 289L, 172L, 35L, 408L, 164L, 91L, 351L, 443L,? 436L, 469L, 186L, 472L, 297L, 50L, 425L, 224L, 3L, 221L, 11L,? 391L, 33L, 243L, 247L, 152L, 98L, 482L, 111L, 257L, 155L, 47L,? 10L, 468L, 270L, 313L, 86L, 293L, 160L, 168L, 409L, 170L, 84L,? 180L, 76L, 99L, 214L, 15L, 414L, 394L, 450L, 4L, 61L, 339L, 342L,? 1L, 470L, 210L, 37L, 345L, 115L, 141L, 302L, 178L, 445L, 6L,? 466L, 285L, 174L, 201L, 114L, 369L, 390L, 69L, 420L, 464L, 269L,? 455L, 382L, 25L, 123L, 95L, 230L, 72L, 250L, 473L, 8L, 274L,? 238L, 62L, 461L, 104L, 125L, 128L, 227L, 292L, 430L, 206L, 360L,? 491L, 191L, 142L, 181L, 318L, 484L, 145L, 89L, 233L, 368L, 412L,? 335L, 215L, 146L, 139L, 426L, 375L, 66L, 299L, 438L, 223L, 175L,? 92L, 225L, 276L, 185L, 336L, 371L, 306L, 366L, 319L, 203L, 44L,? 259L, 23L, 132L, 343L, 447L, 457L, 428L, 359L, 353L, 498L, 169L,? 46L, 29L, 444L, 194L, 439L, 284L, 79L, 226L, 105L, 106L, 326L,? 234L, 196L, 417L, 190L, 480L, 275L, 478L, 341L, 197L, 395L, 85L,? 295L, 70L, 18L, 471L, 218L, 19L, 43L, 280L, 427L, 229L, 5L, 205L,? 494L, 393L, 307L, 465L, 383L, 265L, 103L, 348L, 166L, 58L, 320L,? 14L, 107L, 440L, 24L, 347L, 419L, 135L, 202L, 294L, 173L, 121L,? 358L, 51L, 231L, 118L, 109L, 182L, 219L, 42L, 73L, 435L, 389L,? 431L, 81L, 149L, 388L, 415L, 256L, 312L, 446L, 45L, 162L, 485L,? 154L, 55L, 153L, 137L, 290L, 93L, 40L, 110L, 167L, 315L, 266L,? 317L, 314L, 264L, 277L, 488L, 28L, 354L, 303L, 490L, 192L, 432L,? 228L, 222L, 418L, 323L, 244L, 239L, 193L, 120L, 116L, 148L, 57L,? 246L, 300L, 143L, 208L, 400L, 78L, 273L, 411L, 401L, 476L, 262L,? 159L, 195L, 102L, 75L, 136L, 402L, 32L, 199L, 286L, 477L, 54L,? 429L, 80L, 316L, 30L, 333L, 387L, 452L, 324L, 456L, 39L, 138L,? 113L, 448L, 377L, 122L, 441L, 396L, 454L, 497L, 161L, 21L, 117L,? 413L, 94L, 459L, 156L, 365L, 322L, 397L, 88L, 207L, 150L, 209L,? 184L, 378L, 217L, 176L, 52L, 374L, 189L, 97L, 340L, 357L, 157L,? 220L, 74L, 356L, 495L, 453L, 26L, 499L, 364L, 267L, 331L, 245L,? 258L, 242L, 381L, 36L, 16L, 328L, 131L, 255L, 363L, 298L, 373L,? 416L, 200L, 56L, 263L, 288L, 13L, 305L, 291L, 17L, 53L, 130L,? 458L, 385L, 198L, 158L, 140L, 492L, 249L, 27L, 134L, 479L, 171L,? 177L, 9L, 355L, 398L, 380L, 404L, 304L, 129L, 338L, 281L, 65L,? 386L, 144L, 252L, 77L, 352L, 20L, 96L, 403L, 296L, 268L, 489L,? 63L, 424L, 496L, 126L, 334L, 183L, 232L, 406L, 407L, 163L, 346L,? 287L, 475L, 127L, 321L, 124L, 237L, 308L, 376L, 212L, 423L, 211L,? 329L, 437L, 179L, 253L, 372L, 101L, 251L, 90L, 433L, 311L, 241L,? 327L, 422L, 349L, 493L, 442L, 38L, 449L, 410L, 370L, 421L, 325L,? 451L, 240L, 71L, 392L, 2L, 151L, 332L, 83L, 350L, 87L, 361L,? 330L, 279L, 362L, 310L, 487L, 278L, 367L, 248L, 462L, 59L, 213L,? 68L, 112L, 60L, 481L, 165L, 235L, 22L, 434L, 272L, 460L, 309L,? 301L, 500L, 282L, 82L, 100L, 261L, 34L, 188L, 133L, 344L, 7L,? 486L, 67L, 399L, 254L, 41L, 483L, 64L, 405L, 108L, 236L, 384L,? 467L, 49L, 283L, 119L, 463L, 147L, 379L, 216L, 474L, 204L, 48L,? 260L, 12L, 337L, 187L, 271L, 31L, 289L, 172L, 35L, 408L, 164L,? 91L, 351L, 443L, 436L, 469L, 186L, 472L, 297L, 50L, 425L, 224L,? 3L, 221L, 11L, 391L, 33L, 243L, 247L, 152L, 98L, 482L, 111L,? 257L, 155L, 47L, 10L, 468L, 270L, 313L, 86L, 293L, 160L, 168L,? 409L, 170L, 84L, 180L, 76L, 99L, 214L, 15L, 414L, 394L, 450L,? 4L, 61L, 339L, 342L, 1L, 470L, 210L, 37L, 345L, 115L, 141L, 302L,? 178L, 445L, 6L, 466L, 285L, 174L, 201L, 114L, 369L, 390L, 69L,? 420L, 464L, 269L, 455L, 382L, 25L, 123L, 95L, 230L, 72L, 250L,? 473L, 8L, 274L, 238L, 62L, 461L, 104L, 125L, 128L, 227L, 292L,? 430L, 206L, 360L, 491L, 191L, 142L, 181L, 318L, 484L, 145L, 89L,? 233L, 368L, 412L, 335L, 215L, 146L, 139L, 426L, 375L, 66L, 299L,? 438L, 223L, 175L, 92L, 225L, 276L, 185L, 336L, 371L, 306L, 366L,? 319L), .Dim = c(124L, 8L)) Eliza --> Date: Wed, 27 Feb 2013 05:44:55 -0800 > From: smartpink111 at yahoo.com > Subject: Re: matrix multiplication > To: eliza_botto at hotmail.com > > Hi Elisa, > > Could you just dput that dataset? > Arun > > > > > > > ________________________________ > From: eliza botto <eliza_botto at hotmail.com> > To: "smartpink111 at yahoo.com" <smartpink111 at yahoo.com> > Sent: Wednesday, February 27, 2013 8:38 AM > Subject: matrix multiplication > > > > Dear Arun, > I want to make a distance matrix of the following matrix? > > > ? ? ? ? ?[,1] [,2] ?[,3] [,4] ?[,5] ?[,6] [,7] ?[,8] > ? [1,] ? ?7 ?495 ?106 ?178 ? 39 ?390 ?429 ?14 > ? [2,] ?127 ?457 ? 95 ?193 ?274 ?379 ?468 ? 40 > ? [3,] ?470 ? 30 ? ?1 ?362 ?499 ?478 ?425 ?357 > ? [4,] ?288 ?111 ?463 ?287 ? 85 ?387 ?389 ? 15 > ? [5,] ?416 ?225 ?360 ?317 ? ?7 ?495 ?106 ?178 > ? [6,] ?297 ?438 ?253 ?146 ?127 ?457 ? 95 ?193 > ? [7,] ?323 ? 42 ?234 ? 97 ?470 ? 30 ? ?1 ?362 > ? [8,] ?130 ?352 ?181 ?168 ?288 ?111 ?463 ?287 > ? [9,] ? 53 ?218 ?266 ?133 ?416 ?225 ?360 ?317 > ?[10,] ?232 ?469 ?396 ? ?5 ?297 ?438 ?253 ?146 > ?[11,] ?161 ? 25 ?445 ? 76 ?323 ? 42 ?234 ? 97 > ?[12,] ?169 ?284 ? 99 ?399 ?130 ?352 ?181 ?168 > ?[13,] ? 60 ? 59 ?135 ? ?9 ? 53 ?218 ?266 ?133 > ?[14,] ?415 ? 16 ? 36 ?213 ?232 ?469 ?396 ? ?5 > ?[15,] ? 22 ?249 ? 82 ?334 ?161 ? 25 ?445 ? 76 > ?[16,] ?455 ?395 ? 41 ?192 ?169 ?284 ? 99 ?399 > ?[17,] ?431 ?400 ?302 ?461 ? 60 ? 59 ?135 ? ?9 > ?[18,] ?139 ?175 ? 28 ?283 ?415 ? 16 ? 36 ?213 > ?[19,] ?316 ?327 ?486 ?180 ? 22 ?249 ? 82 ?334 > ?[20,] ? 77 ?339 ?410 ?173 ?455 ?395 ? 41 ?192 > ?[21,] ?260 ?293 ?100 ?147 ?431 ?400 ?302 ?461 > ?[22,] ?418 ?109 ?476 ? 87 ?139 ?175 ? 28 ?283 > ?[23,] ?254 ?426 ?443 ? 98 ?316 ?327 ?486 ?180 > ?[24,] ?377 ?149 ?314 ?198 ? 77 ?339 ?410 ?173 > ?[25,] ?318 ?485 ?203 ?394 ?260 ?293 ?100 ?147 > ?[26,] ?313 ? 51 ?289 ?296 ?418 ?109 ?476 ? 87 > ?[27,] ?371 ?247 ?348 ? 80 ?254 ?426 ?443 ? 98 > ?[28,] ?256 ? 96 ?132 ?208 ?377 ?149 ?314 ?198 > ?[29,] ?204 ?330 ?226 ?430 ?318 ?485 ?203 ?394 > ?[30,] ?300 ?164 ?325 ?148 ?313 ? 51 ?289 ?296 > ?[31,] ?105 ?153 ?241 ?454 ?371 ?247 ?348 ? 80 > ?[32,] ?107 ?267 ?294 ?424 ?256 ? 96 ?132 ?208 > ?[33,] ? 34 ? 63 ?282 ?156 ?204 ?330 ?226 ?430 > ?[34,] ? 73 ?321 ?482 ?483 ?300 ?164 ?325 ?148 > ?[35,] ?401 ?272 ? 44 ?137 ?105 ?153 ?241 ?454 > ?[36,] ?484 ?310 ?141 ?221 ?107 ?267 ?294 ?424 > ?[37,] ? 33 ?258 ?382 ? 72 ? 34 ? 63 ?282 ?156 > ?[38,] ?176 ?167 ?388 ? 78 ? 73 ?321 ?482 ?483 > ?[39,] ? 70 ?177 ?350 ?271 ?401 ?272 ? 44 ?137 > ?[40,] ?479 ?201 ?345 ? 19 ?484 ?310 ?141 ?221 > ?[41,] ? ?4 ?423 ?343 ?437 ? 33 ?258 ?382 ? 72 > ?[42,] ?187 ?493 ?337 ?233 ?176 ?167 ?388 ? 78 > ?[43,] ?473 ?481 ?406 ?422 ? 70 ?177 ?350 ?271 > ?[44,] ?413 ?368 ?500 ?448 ?479 ?201 ?345 ? 19 > ?[45,] ?419 ?138 ?252 ?378 ? ?4 ?423 ?343 ?437 > ?[46,] ?227 ? ?3 ?471 ?235 ?187 ?493 ?337 ?233 > ?[47,] ?374 ?311 ?136 ?110 ?473 ?481 ?406 ?422 > ?[48,] ?381 ? 46 ? 89 ?480 ?413 ?368 ?500 ?448 > ?[49,] ?336 ?402 ?268 ?144 ?419 ?138 ?252 ?378 > ?[50,] ?290 ?199 ?491 ?414 ?227 ? ?3 ?471 ?235 > ?[51,] ? 48 ?351 ? 81 ?155 ?374 ?311 ?136 ?110 > ?[52,] ?251 ?189 ?280 ?326 ?381 ? 46 ? 89 ?480 > ?[53,] ?117 ?102 ?179 ?185 ?336 ?402 ?268 ?144 > ?[54,] ?465 ?160 ?475 ?496 ?290 ?199 ?491 ?414 > ?[55,] ?122 ?142 ?188 ?384 ? 48 ?351 ? 81 ?155 > ?[56,] ?279 ?223 ?407 ?222 ?251 ?189 ?280 ?326 > ?[57,] ?134 ?112 ?435 ? 21 ?117 ?102 ?179 ?185 > ?[58,] ?219 ? 54 ?207 ?281 ?465 ?160 ?475 ?496 > ?[59,] ?404 ?492 ?157 ?125 ?122 ?142 ?188 ?384 > ?[60,] ?285 ? 68 ?441 ? 57 ?279 ?223 ?407 ?222 > ?[61,] ?151 ?244 ?131 ?108 ?134 ?112 ?435 ? 21 > ?[62,] ?261 ?220 ?216 ? 45 ?219 ? 54 ?207 ?281 > ?[63,] ?145 ? 29 ?488 ?184 ?404 ?492 ?157 ?125 > ?[64,] ? 58 ?129 ? 65 ?276 ?285 ? 68 ?441 ? 57 > ?[65,] ?434 ?444 ?456 ?123 ?151 ?244 ?131 ?108 > ?[66,] ?275 ?217 ?154 ?171 ?261 ?220 ?216 ? 45 > ?[67,] ? 13 ?299 ?428 ?346 ?145 ? 29 ?488 ?184 > ?[68,] ?165 ?451 ? 86 ? 50 ? 58 ?129 ? 65 ?276 > ?[69,] ?237 ?319 ?442 ?427 ?434 ?444 ?456 ?123 > ?[70,] ?242 ?191 ?453 ?230 ?275 ?217 ?154 ?171 > ?[71,] ?159 ?197 ?344 ?432 ? 13 ?299 ?428 ?346 > ?[72,] ?206 ?115 ?375 ?329 ?165 ?451 ? 86 ? 50 > ?[73,] ?114 ?259 ?209 ?295 ?237 ?319 ?442 ?427 > ?[74,] ?248 ?380 ?172 ? 12 ?242 ?191 ?453 ?230 > ?[75,] ?408 ?472 ?273 ?477 ?159 ?197 ?344 ?432 > ?[76,] ?367 ?162 ?190 ?240 ?206 ?115 ?375 ?329 > ?[77,] ?307 ? 66 ?450 ?250 ?114 ?259 ?209 ?295 > ?[78,] ?331 ? 31 ?163 ?166 ?248 ?380 ?172 ? 12 > ?[79,] ?376 ?464 ? 75 ? 93 ?408 ?472 ?273 ?477 > ?[80,] ?194 ?366 ? 35 ?359 ?367 ?162 ?190 ?240 > ?[81,] ?210 ? ?8 ? 20 ?364 ?307 ? 66 ?450 ?250 > ?[82,] ?436 ?391 ?320 ?354 ?331 ? 31 ?163 ?166 > ?[83,] ?324 ? 90 ?186 ?239 ?376 ?464 ? 75 ? 93 > ?[84,] ?212 ?196 ?128 ? 47 ?194 ?366 ? 35 ?359 > ?[85,] ? 32 ?298 ?292 ?202 ?210 ? ?8 ? 20 ?364 > ?[86,] ? 43 ?182 ?245 ?466 ?436 ?391 ?320 ?354 > ?[87,] ?278 ? 37 ?265 ?412 ?324 ? 90 ?186 ?239 > ?[88,] ?101 ? 88 ? 79 ?205 ?212 ?196 ?128 ? 47 > ?[89,] ?308 ?439 ? 62 ?312 ? 32 ?298 ?292 ?202 > ?[90,] ? ?6 ? 10 ? 94 ?301 ? 43 ?182 ?245 ?466 > ?[91,] ?361 ?347 ?392 ? 71 ?278 ? 37 ?265 ?412 > ?[92,] ?497 ?467 ? 11 ?386 ?101 ? 88 ? 79 ?205 > ?[93,] ?270 ?309 ?116 ?452 ?308 ?439 ? 62 ?312 > ?[94,] ?152 ?341 ? 24 ?315 ? ?6 ? 10 ? 94 ?301 > ?[95,] ?421 ?229 ?458 ?291 ?361 ?347 ?392 ? 71 > ?[96,] ? 92 ?269 ?356 ?393 ?497 ?467 ? 11 ?386 > ?[97,] ? 18 ?277 ? 84 ?487 ?270 ?309 ?116 ?452 > ?[98,] ?349 ?370 ?397 ?494 ?152 ?341 ? 24 ?315 > ?[99,] ? 27 ?446 ?103 ?417 ?421 ?229 ?458 ?291 > [100,] ? 69 ?383 ?409 ?246 ? 92 ?269 ?356 ?393 > [101,] ? ?2 ?328 ?385 ?353 ? 18 ?277 ? 84 ?487 > [102,] ?474 ?255 ?403 ? 52 ?349 ?370 ?397 ?494 > [103,] ? 38 ?140 ? 61 ?257 ? 27 ?446 ?103 ?417 > [104,] ?263 ?373 ?332 ?215 ? 69 ?383 ?409 ?246 > [105,] ? 91 ? 17 ?333 ?143 ? ?2 ?328 ?385 ?353 > [106,] ?460 ?358 ?224 ? 23 ?474 ?255 ?403 ? 52 > [107,] ?398 ?433 ?369 ?121 ? 38 ?140 ? 61 ?257 > [108,] ?303 ?120 ?365 ?113 ?263 ?373 ?332 ?215 > [109,] ?411 ?231 ?286 ?174 ? 91 ? 17 ?333 ?143 > [110,] ?158 ?200 ?449 ?211 ?460 ?358 ?224 ? 23 > [111,] ?306 ? 56 ? 74 ?338 ?398 ?433 ?369 ?121 > [112,] ?498 ?150 ?236 ?440 ?303 ?120 ?365 ?113 > [113,] ?104 ?243 ?170 ?304 ?411 ?231 ?286 ?174 > [114,] ?183 ?489 ? 49 ? 55 ?158 ?200 ?449 ?211 > [115,] ?195 ?355 ?363 ?322 ?306 ? 56 ? 74 ?338 > [116,] ? 64 ?335 ?228 ?342 ?498 ?150 ?236 ?440 > [117,] ?305 ?214 ?262 ?405 ?104 ?243 ?170 ?304 > [118,] ?447 ?124 ?340 ?118 ?183 ?489 ? 49 ? 55 > [119,] ?238 ?126 ?264 ? 67 ?195 ?355 ?363 ?322 > [120,] ?119 ?372 ?490 ? 26 ? 64 ?335 ?228 ?342 > [121,] ?390 ?429 ? 14 ?420 ?305 ?214 ?262 ?405 > [122,] ?379 ?468 ? 40 ?459 ?447 ?124 ?340 ?118 > [123,] ?478 ?425 ?357 ? 83 ?238 ?126 ?264 ? 67 > [124,] ?387 ?389 ? 15 ?462 ?119 ?372 ?490 ? 26 > > i want to have a distance matrix generated on the following procedure > > >Subtraction should take place row-wise > > > > Subtraction of second row from first row > ========================> ={abs[(1,1)-(2,1)]*abs[(1,5)-(2,5)]}+{abs[(1,2)-(2,2)]*abs[(1,6)-(2,6)]}+{abs[(1,3)-(2,3)]*abs[(1,7)-(2,7)]}+{abs[(1,4)-(2,4)]*abs[(1,8)-(2,8)]} > where in (1,1) first coordinate figure is row number and second is column number > so ?if we put the values in above line, we should get > ={abs[(7)-(127)]*abs[(39)-(274)]}+{abs[(495)-(457)]*abs[(390)-(379)]}+{abs[(106)-(95)]*abs[(429)-(468)]}+{abs[(178)-(193)]*abs[(14)-(40)]} > =29437 > Subtraction of third row from first row > ========================> ={abs[(1,1)-(3,1)]*abs[(1,5)-(3,5)]}+{abs[(1,2)-(3,2)]*abs[(1,6)-(3,6)]}+{abs[(1,3)-(3,3)]*abs[(1,7)-(3,7)]}+{abs[(1,4)-(3,4)]*abs[(1,8)-(3,8)]} > > when all the rows are subtracted from from 1. then all the rows should be subtracted from row 2 and then from row 3 and so on.... till 124th row. So, what i want to have in the end is a distance matrix with same upper and lower triangle and 0's on diagonal. > > Thankyou so very much in advance > > ELIZA