Using MATLAB (779505), страница 69

Файл №779505 Using MATLAB (Using MATLAB) 69 страницаUsing MATLAB (779505) страница 692017-12-27СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 69)

The numbering used by bucky.m is based on thepentagons inherent in the ball’s structure.16-1916Sparse MatricesThe vertices of one pentagon are numbered 1 through 5, the vertices of anadjacent pentagon are numbered 6 through 10, and so on. The picture on thefollowing page shows the numbering of half of the nodes (one hemisphere); thenumbering of the other hemisphere is obtained by a reflection about theequator. Use gplot to produce a graph showing half the nodes.

You can add thenode numbers using a for loop.k = 1:30;gplot(B(k,k),v);axis squarefor j = 1:30, text(v(j,1),v(j,2), int2str(j)); end11415130.8181711120.60.419162200.2103901−0.2226485−0.423721−0.626243025−0.827−1−1−0.8−0.6−0.4−0.2029280.20.40.60.81To view a template of the nonzero locations in the Bucky ball’s adjacencymatrix, use the spy function:spy(B)16-20Example: Adjacency Matrices and Graphs01020304050600102030nz = 180405060The node numbering that this model uses generates a spy plot with 12 groupsof five elements, corresponding to the 12 pentagons in the structure. Each nodeis connected to two other nodes within its pentagon and one node in some otherpentagon.

Since the nodes within each pentagon have consecutive numbers,most of the elements in the first super- and sub-diagonals of B are nonzero. Inaddition, the symmetry of the numbering about the equator is apparent in thesymmetry of the spy plot about the antidiagonal.Graphs and Characteristics of Sparse MatricesSpy plots of the matrix powers of B illustrate two important concepts related tosparse matrix operations, fill-in and distance.

spy plots help illustrate theseconcepts.spy(B^2)spy(B^3)spy(B^4)spy(B^8)16-2116Sparse Matrices0010102020303040405050606002040nz = 4206000101020203030404050506002040nz = 7806002040nz = 3540606002040nz = 138060Fill-in is generated by operations like matrix multiplication. The product oftwo or more matrices usually has more nonzero entries than the individualterms, and so requires more storage. As p increases, B^p fills in and spy(B^p)gets more dense.The distance between two nodes in a graph is the number of steps on the graphnecessary to get from one node to the other.

The spy plot of the p-th power of Bshows the nodes that are a distance p apart. As p increases, it is possible to getto more and more nodes in p steps. For the Bucky ball, B^8 is almost completelyfull. Only the antidiagonal is zero, indicating that it is possible to get from anynode to any other node, except the one directly opposite it on the sphere, ineight steps.16-22Example: Adjacency Matrices and GraphsAn Airflow ModelA calculation performed at NASA’s Research Institute for Applications ofComputer Science involves modeling the flow over an airplane wing with twotrailing flaps.10.90.80.70.60.50.40.30.20.1000.10.20.30.40.50.60.70.80.91In a two-dimensional model, a triangular grid surrounds a cross section of thewing and flaps.

The partial differential equations are nonlinear and involveseveral unknowns, including hydrodynamic pressure and two components ofvelocity. Each step of the nonlinear iteration requires the solution of a sparselinear system of equations. Since both the connectivity and the geometriclocation of the grid points are known, the gplot function can produce the graphshown above.In this example, there are 4253 grid points, each of which is connected tobetween 3 and 9 others, for a total of 28831 nonzeros in the matrix, and adensity equal to 0.0016.

This spy plot shows that the node numbering yields adefinite band structure.16-2316Sparse MatricesThe Laplacian of the mesh.0 ........................................5001000150020002500300035004000.. ............................................... .............. . .

... . ..................................................................................... .. ..... . .... .... ............ ......................................... . ...... . .............................................................. .. ... ...

. . .......................... ... .. ... .... . ........................ .. . . .............. . ....................................... .. ... ........ ............................................ ... . ... .. .. ....... ................................... .... . . ........................... ...... .. ... ..................................................... . .... ........................................

........ ............................................. .. ....................... ............................................................... .................................... .. .. ............................... . ....... .... . . .. . ..... ................................................... ...... . .. ... .............................................. .. .

... .. ................................................ . . . . ... . .. ..... ... .. ................................................ .. ....... .. . . .. . ... .. ....................................................... ............. .... . ... ......................... ........................................................................... . . .. . .. .. .. .. ........................ .. .

.. . . . .. .. .. . . ................................................................. . ... . ........................................................... .. ...................................................... .. . .... . ............. .... ... .. . .. .

. ... .............................................. ........ .. .. . .. .. . .. ..... ... ... . .... ......................................................... . .. . . .. .................................................. .. . .................. ... ... ................................ . . .. . ....

. .. . . ....................................................... ...... ..... .............................................. .. .............. .... . .. .. ............................................................. . ................................ . . ................................................................ .

........................... . .................. ....010002000nz = 2883116-2430004000Sparse Matrix OperationsSparse Matrix OperationsMost of MATLAB’s standard mathematical functions work on sparse matricesjust as they do on full matrices. In addition, MATLAB provides a number offunctions that perform operations specific to sparse matrices.

This sectiondiscusses:• Computational considerations• Standard mathematical operations• Permutation and reordering• Factorization• Simultaneous linear equations• Eigenvalues and singular valuesComputational ConsiderationsThe computational complexity of sparse operations is proportional to nnz, thenumber of nonzero elements in the matrix. Computational complexity alsodepends linearly on the row size m and column size n of the matrix, but isindependent of the product m*n, the total number of zero and nonzero elements.The complexity of fairly complicated operations, such as the solution of sparselinear equations, involves factors like ordering and fill-in, which are discussedin the previous section.

In general, however, the computer time required for asparse matrix operation is proportional to the number of arithmetic operationson nonzero quantities.Standard Mathematical OperationsSparse matrices propagate through computations according to these rules:• Functions that accept a matrix and return a scalar or vector always produceoutput in full storage format. For example, the size function always returnsa full vector, whether its input is full or sparse.• Functions that accept scalars or vectors and return matrices, such as zeros,ones, rand, and eye, always return full results.

This is necessary to avoidintroducing sparsity unexpectedly. The sparse analog of zeros(m,n) issimply sparse(m,n). The sparse analogs of rand and eye are sprand andspeye, respectively. There is no sparse analog for the function ones.16-2516Sparse Matrices• Unary functions that accept a matrix and return a matrix or vector preservethe storage class of the operand.

If S is a sparse matrix, then chol(S) is alsoa sparse matrix, and diag(S) is a sparse vector. Columnwise functions suchas max and sum also return sparse vectors, even though these vectors may beentirely nonzero. Important exceptions to this rule are the sparse and fullfunctions.• Binary operators yield sparse results if both operands are sparse, and fullresults if both are full. For mixed operands, the result is full unless theoperation preserves sparsity. If S is sparse and F is full, then S+F, S*F, andF\S are full, while S.*F and S&F are sparse. In some cases, the result mightbe sparse even though the matrix has few zero elements.• Matrix concatenation using either the cat function or square bracketsproduces sparse results for mixed operands.• Submatrix indexing on the right side of an assignment preserves the storageformat of the operand unless the result is a scalar.

Характеристики

Тип файла
PDF-файл
Размер
6,57 Mb
Материал
Тип материала
Высшее учебное заведение

Список файлов книги

Свежие статьи
Популярно сейчас
Зачем заказывать выполнение своего задания, если оно уже было выполнено много много раз? Его можно просто купить или даже скачать бесплатно на СтудИзбе. Найдите нужный учебный материал у нас!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
7006
Авторов
на СтудИзбе
261
Средний доход
с одного платного файла
Обучение Подробнее
{user_main_secret_data}