<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1582115</guid>
        <pubDate>Mon, 28 May 2007 18:20:57 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1582115</link>
        <description><![CDATA[byte: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=55150&view=findpost&p=365866'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Adil &#064; <time class="tag-quote__quoted-time" datetime="2004-05-26T12:12:10+04:00">26.05.04, 08:12</time></span><div class='quote '>А применительно к обращению матрицы это, образно говоря, приводишь матрицу к единичной, синхронно производя такие же действия на единичной матрицой; вот то, что останется от второй и будет обращенная матрица к первой.</div></div><br>
Все правильно, это и есть алгоритм Гаусса для нахождения обратной матрицы.<br>
Сам недавно писал :yes:]]></description>
        <author>byte</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1582098</guid>
        <pubDate>Mon, 28 May 2007 17:55:01 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1582098</link>
        <description><![CDATA[Mr.Delphist: Коллеги, про ошибки округления также не забываем. А они могут ой как стукнуть при расчете обратной матрицы на некоторых &quot;неудобных&quot; примерах.]]></description>
        <author>Mr.Delphist</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1581903</guid>
        <pubDate>Mon, 28 May 2007 14:56:37 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1581903</link>
        <description><![CDATA[Serfess: Понял &#33; Ошибка была в том, что я лопухнулся и попутался с определением единичной матрицы (стыд мне и позор )))))&#33;<br>Спасибо за помощь&#33; и коррекцию кода сообщения в форуме и самой программы&#33;&#33;&#33;&#33;&#33;&#33;&#33;<br>PS: Переделал проверил - все просто отлично&#33;&#33;&#33;]]></description>
        <author>Serfess</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1581888</guid>
        <pubDate>Mon, 28 May 2007 14:47:54 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1581888</link>
        <description><![CDATA[Adil: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=55150&view=findpost&p=1581871'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Serfess &#064; <time class="tag-quote__quoted-time" datetime="2007-05-28T14:38:20+00:00">28.05.07, 14:38</time></span><div class='quote '>a1[0]=-1;a1[1]=0;a1[2]=3;a1[3]=2;a1[4]=2;a1[5]=1;a1[6]=1;a1[7]=-1;a1[8]=2;</div></div><br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=55150&view=findpost&p=1581844'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Serfess &#064; <time class="tag-quote__quoted-time" datetime="2007-05-28T14:10:45+00:00">28.05.07, 14:10</time></span><div class='quote '>-1 2 1<br>
0 2 -1<br>
3 1 2</div></div>Вообщем-то подразумевалось, что <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=55150&view=findpost&p=1042264'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Adil &#064; <time class="tag-quote__quoted-time" datetime="2006-03-13T09:37:39+00:00">13.03.06, 09:37</time></span><div class='quote '>//buf - заданная матрица размером row-строк на col-столбцов<br>
// это одномерный массив, доступ к элементу (i,j) - типа buf[i*col+j]</div></div> i -строка, j-столбец, но это не важно, важно, что<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=55150&view=findpost&p=366072'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Adil &#064; <time class="tag-quote__quoted-time" datetime="2004-05-26T11:28:29+00:00">26.05.04, 11:28</time></span><div class='quote '>//buf и resbuf - матрицы размером row-строк на col-столбцов<br>
// это одномерные массивы, доступ к элементу (i,j) - типа buf[i*col+j]<br>
//buf - заданная матрица (портится&#33;), resbuf - выходная такого же размера <span class="tag-color tag-color-named" data-value="red" style="color: red"><strong class='tag-b'>(на входе должна быть единичной&#33;)</strong></span></div></div><br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=55150&view=findpost&p=1581871'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Serfess &#064; <time class="tag-quote__quoted-time" datetime="2007-05-28T14:38:20+00:00">28.05.07, 14:38</time></span><div class='quote '>Стиль конечно не ахти</div></div>Ну а тег CODE можно ведь было это засунуть? :( <br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=55150&view=findpost&p=1581871'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Serfess &#064; <time class="tag-quote__quoted-time" datetime="2007-05-28T14:38:20+00:00">28.05.07, 14:38</time></span><div class='quote '>a1[0]=-1;a1[1]=0;a1[2]=3;a1[3]=2;a1[4]=2;a1[5]=1;a1[6]=1;a1[7]=-1;a1[8]=2;</div></div>И не лень было расписывать?<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">double a1[9]= {</div><div class="code_line">-1, 2, 1,</div><div class="code_line">0, 2, -1,</div><div class="code_line">3, 1, 2};</div><div class="code_line">double a2[9]= {</div><div class="code_line">1, 0, 0,</div><div class="code_line">0, 1, 0,</div><div class="code_line">0, 0, 1};</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=55150&view=findpost&p=1581871'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Serfess &#064; <time class="tag-quote__quoted-time" datetime="2007-05-28T14:38:20+00:00">28.05.07, 14:38</time></span><div class='quote '>p1=&amp;a1[0];<br>
p2=&amp;a2[0];</div></div>Зачем эти указатели? Можно было сразу E_1(a1,a2,3,3);]]></description>
        <author>Adil</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1581871</guid>
        <pubDate>Mon, 28 May 2007 14:38:20 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1581871</link>
        <description><![CDATA[Serfess: <div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">//меняет строки i и j местами</div><div class="code_line">void changerow(double *buf, int i, int j, int col)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp;int sz = sizeof(double)*col;</div><div class="code_line">&nbsp;&nbsp;double *help = new double[sz];</div><div class="code_line">&nbsp;&nbsp;memcpy(help, &amp;buf[i*col], sz);</div><div class="code_line">&nbsp;&nbsp;memcpy(&amp;buf[i*col], &amp;buf[j*col], sz);</div><div class="code_line">&nbsp;&nbsp;memcpy(&amp;buf[j*col], help, sz);</div><div class="code_line">&nbsp;&nbsp;delete[] help;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">int E_1(double *buf, double *resbuf, int row, int col)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp;if(row!=col)</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0; //ошибка: в этой функции обращаем только квадратые непустые матрицы</div><div class="code_line">&nbsp;&nbsp;double del,mul;</div><div class="code_line">&nbsp;&nbsp;//Идем вниз</div><div class="code_line">&nbsp;&nbsp;for(int f, i=0; i&#60;row; ++i)</div><div class="code_line">&nbsp;&nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;f=row-1;</div><div class="code_line">&nbsp;&nbsp; &nbsp;while( fabs(buf[i*col+i])&#60;=MINDOUBLE ) // &#60;=&#62; while( buf[i*col+i]==0 )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{//диагональный элемент равен 0</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if(f==i)</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0; // ошибка: линейно-зависимая матрица;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;//переставляем строки, пока не найдем с ненулевым элементом</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;changerow(buf, i, f, col);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;changerow(resbuf, i, f--, col);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;del = buf[i*col+i];</div><div class="code_line">&nbsp;&nbsp; &nbsp;if( fabs(del - 1.)&#62;MINDOUBLE ) // &#60;=&#62; if( del!=1 )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;buf[i*col+i] = 1.;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;for(int j=i+1; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp;buf[i*col+j] /= del;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;for(j=0; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp;resbuf[i*col+j]/=del;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(int k=i+1; k&#60;row; ++k)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if( fabs(buf[k*col+i])&#62;MINDOUBLE ) // &#60;=&#62; if(buf[k*col+i]!=0.)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;mul = buf[k*col+i];</div><div class="code_line">&nbsp;&nbsp; &nbsp;buf[k*col+i] = 0.;</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(int j=i+1; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;buf[k*col+j] -= mul*buf[i*col+j];</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(j=0; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;resbuf[k*col+j] -= mul*resbuf[i*col+j];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp;}</div><div class="code_line">&nbsp;&nbsp;//Идем вверх</div><div class="code_line">&nbsp;&nbsp;for(i=row; --i&#62;=0; )</div><div class="code_line">&nbsp;&nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(int k=i; --k&#62;=0; )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if( fabs(buf[k*col+i])&#62;MINDOUBLE) // &#60;=&#62; if(buf[k*col+i]!=0.)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;mul = buf[k*col+i];</div><div class="code_line">&nbsp;&nbsp; &nbsp;buf[k*col+i] = 0.;</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(int j=0; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;resbuf[k*col+j] -= mul*resbuf[i*col+j];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp;}</div><div class="code_line">&nbsp;&nbsp;return 1;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">double a1[9],a2[9];</div><div class="code_line">double *p1,*p2;</div><div class="code_line">void main()</div><div class="code_line">{</div><div class="code_line">&nbsp;clrscr();</div><div class="code_line">&nbsp;p1=&amp;a1[0];</div><div class="code_line">&nbsp;p2=&amp;a2[0];</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;a1[0]=-1;a1[1]=0;a1[2]=3;a1[3]=2;a1[4]=2;a1[5]=1;a1[6]=1;a1[7]=-1;a1[8]=2;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;for(int i=0;i&#60;9;i++) a2[i]=1;</div><div class="code_line">&nbsp;E_1(p1,p2,3,3);</div><div class="code_line">&nbsp;for(i=0;i&#60;9;i++) cout&#60;&#60;a2[i]&#60;&#60;endl;</div><div class="code_line">// for(i=0;i&#60;3;i++)</div><div class="code_line">// &nbsp;for(int j=0;j&#60;3;j++)</div><div class="code_line">// &nbsp; a_1[i][j]=a2[i*3 + j];</div><div class="code_line">// VivMatr(3,3,a_1,5,5);</div><div class="code_line">&nbsp;getch();</div><div class="code_line">&nbsp;</div><div class="code_line">}</div></ol></div></div></div></div><br>
Стиль конечно не ахти - но это всего лишь тест - мне важно скорее время ))). Всмысле сессия скоро&#33;]]></description>
        <author>Serfess</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1581862</guid>
        <pubDate>Mon, 28 May 2007 14:21:58 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1581862</link>
        <description><![CDATA[Adil: Приведи свой код.]]></description>
        <author>Adil</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1581844</guid>
        <pubDate>Mon, 28 May 2007 14:10:45 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1581844</link>
        <description><![CDATA[Serfess: Adil&#33; <br>Вычисляю прогиб балки - вобщем ДЗ у меня таакое. Мне необходимо  найти обратную матрицу - вот взял твои примеры&#33;<br>Беру для теста матрицу<br>-1  2  1<br>0  2  -1<br>3  1   2<br>Детерминант находит правильно - то есть =-17&#33;<br><br>А вот обратную матрицу выдает странну и неправильную ... -<br>0.117647<br>0.117647<br>0.117647<br>0.529412<br>0.529412<br>0.529412<br>0.058824<br>0.058824<br>0.058824<br><br>Не поможешь разобратся, где ошибка... я на BC 3.1 пишу - такие условия ...]]></description>
        <author>Serfess</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1042264</guid>
        <pubDate>Mon, 13 Mar 2006 09:37:39 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=1042264</link>
        <description><![CDATA[Adil: Так как часто задают вопросы про определитель, вот переделка под вычисление определителя:<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">//buf - заданная матрица размером row-строк на col-столбцов</div><div class="code_line">// это одномерный массив, доступ к элементу (i,j) - типа buf[i*col+j]</div><div class="code_line">//buf - портится!; </div><div class="code_line">//Результат возвращается через указатель det; функция возвращает false, если нельзя найти (*det тогда м.б. любым). </div><div class="code_line">//для MINFLOAT надо подключить values.h</div><div class="code_line">//для fabs надо подключить math.h</div><div class="code_line">bool Det(double *buf, int row, int col, double* det)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp;if(row!=col) </div><div class="code_line">&nbsp;&nbsp; &nbsp;return false; //ошибка: в этой функции обращаем только квадратые непустые матрицы</div><div class="code_line">&nbsp;&nbsp;double del, mul;</div><div class="code_line">&nbsp;&nbsp;*det = 1.;</div><div class="code_line">&nbsp;&nbsp;//Идем вниз</div><div class="code_line">&nbsp;&nbsp;for(int f, i=0; i&#60;row; ++i)</div><div class="code_line">&nbsp;&nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;f = row-1;</div><div class="code_line">&nbsp;&nbsp; &nbsp;while( fabs(buf[i*col+i])&#60;=MINFLOAT ) // &#60;=&#62; while( buf[i*col+i]==0 )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{//диагональный элемент равен 0</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if( f==i )</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return false; // ошибка: линейно-зависимая матрица;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;//переставляем строки, пока не найдем с ненулевым элементом</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;chagerow(buf, i, f--, col);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;det *= -1.;//вроде бы при перестановке строк определитель меняет знак?</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;del = buf[i*col+i];</div><div class="code_line">&nbsp;&nbsp; &nbsp;if( fabs(del - 1.)&#62;MINFLOAT ) // &#60;=&#62; if( del!=1 )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;buf[i*col+i] = 1.;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;for(int j=i+1; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;buf[i*col+j] /= del;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;(*det) *= del;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(int k=i+1; k&#60;row; ++k)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if( fabs(buf[k*col+i])&#62;MINFLOAT ) // &#60;=&#62; if(buf[k*col+i]!=0.)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;mul = buf[k*col+i];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;buf[k*col+i] = 0.;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for(int j=i+1; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;buf[k*col+j] -= mul*buf[i*col+j];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp;}</div><div class="code_line">&nbsp;&nbsp;return true;</div><div class="code_line">}</div><div class="code_line">//меняет строки i и j местами</div><div class="code_line">void changerow(double *buf, int i, int j, int col)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp;int sz = sizeof(double)*col;</div><div class="code_line">&nbsp;&nbsp;double *help = new double[sz];</div><div class="code_line">&nbsp;&nbsp;memcpy(help, &amp;buf[i*col], sz);</div><div class="code_line">&nbsp;&nbsp;memcpy(&amp;buf[i*col], &amp;buf[f*col], sz);</div><div class="code_line">&nbsp;&nbsp;memcpy(&amp;buf[f*col], help, sz);</div><div class="code_line">&nbsp;&nbsp;delete[] help;</div><div class="code_line">}</div></ol></div></div></div></div> Правил &quot;налету&quot;, так что проверяйте...]]></description>
        <author>Adil</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=371997</guid>
        <pubDate>Wed, 02 Jun 2004 15:25:45 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=371997</link>
        <description><![CDATA[Technos: <a class='tag-url' href='http://www.codeproject.com/cpp/IsrMatrixCalc.asp' target='_blank'>Посмотри тут</a> может поможет]]></description>
        <author>Technos</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=368650</guid>
        <pubDate>Sat, 29 May 2004 11:29:43 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=368650</link>
        <description><![CDATA[kostya_: А нету алгоритма с двумерными массивами вместо одномерных.]]></description>
        <author>kostya_</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=366438</guid>
        <pubDate>Wed, 26 May 2004 19:34:45 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=366438</link>
        <description><![CDATA[Sanek: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>читай мой пост</div></div><br>
и что?]]></description>
        <author>Sanek</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=366244</guid>
        <pubDate>Wed, 26 May 2004 14:43:06 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=366244</link>
        <description><![CDATA[Adil: Ну так и правильно - то, что в моем коде от <strong class='tag-b'>//Идем вниз</strong> до <strong class='tag-b'>//Идем вверх</strong> - и есть приведение к верхнетреугольному виду, это <strong class='tag-b'>прямой</strong> алгоритм Гаусса; а то, что после <strong class='tag-b'>//Идем вверх</strong> - приведение верхнетреугольной матрицы к единичной-диагональной - это <strong class='tag-b'>обратный</strong> алгоритм Гаусса.<br>
<br>
P.S. Если я ничего не путаю, конечно  ;)]]></description>
        <author>Adil</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=366214</guid>
        <pubDate>Wed, 26 May 2004 14:14:49 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=366214</link>
        <description><![CDATA[Sanek: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>Ну ты наверно еще с каким-нибудь гауссом перепутал, плодовитый товарищ был.  <br>
А применительно к обращению матрицы это, образно говоря, приводишь матрицу к единичной, синхронно производя такие же действия на единичной матрицой; вот то, что останется от второй и будет обращенная матрица к первой<br>
</div></div><br>
А разве это - алгоритм Гаусса? Я знаю алгоритм Гаусса - приведение матрицы к верхнетреугольному виду. В общем я просто не понял, что имелось в виду под алгоритмом Гаусса.]]></description>
        <author>Sanek</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=366174</guid>
        <pubDate>Wed, 26 May 2004 13:15:27 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=366174</link>
        <description><![CDATA[prografix: Желающие могут посмотреть <a class='tag-url' href='http://www.prografix.narod.ru/rus_matrix.html' target='_blank'>http://www.prografix.narod.ru/rus_matrix.html</a><br>
Там много операций с матрицами в том числе и обращение ( inverse )]]></description>
        <author>prografix</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=366072</guid>
        <pubDate>Wed, 26 May 2004 11:28:29 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=366072</link>
        <description><![CDATA[Adil: Причем гаусс и в реализации проще, а о времени выполнения я уж и не говорю...<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">//buf и resbuf - матрицы размером row-строк на col-столбцов</div><div class="code_line">// это одномерные массивы, доступ к элементу (i,j) - типа buf[i*col+j]</div><div class="code_line">//buf - заданная матрица (портится!), resbuf - выходная такого же размера (на входе должна быть единичной!)</div><div class="code_line">//возвращает false, если не может найти</div><div class="code_line">//для MINFLOAT надо подключить values.h</div><div class="code_line">//для fabs надо подключить math.h</div><div class="code_line">bool E_1(double *buf, double *resbuf, int row, int col)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp;if(row!=col)</div><div class="code_line">&nbsp;&nbsp; &nbsp;return false; //ошибка: в этой функции обращаем только квадратые непустые матрицы</div><div class="code_line">&nbsp;&nbsp;double del,mul;</div><div class="code_line">&nbsp;&nbsp;//Идем вниз</div><div class="code_line">&nbsp;&nbsp;for(int f, i=0; i&#60;row; ++i)</div><div class="code_line">&nbsp;&nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;f=row-1;</div><div class="code_line">&nbsp;&nbsp; &nbsp;while( fabs(buf[i*col+i])&#60;=MIN_FLOAT ) // &#60;=&#62; while( buf[i*col+i]==0 )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{//диагональный элемент равен 0</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if(f==i)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return false; // ошибка: линейно-зависимая матрица;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;//переставляем строки, пока не найдем с ненулевым элементом</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;chagerow(buf, i, f, col);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;chagerow(resbuf, i, f--, col);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;del = buf[i*col+i];</div><div class="code_line">&nbsp;&nbsp; &nbsp;if( fabs(del - 1.)&#62;MINFLOAT ) // &#60;=&#62; if( del!=1 )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;buf[i*col+i] = 1.;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;for(int j=i+1; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;buf[i*col+j] /= del;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;for(int j=0; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resbuf[i*col+j]/=del;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(int k=i+1; k&#60;row; ++k)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if( fabs(buf[k*col+i])&#62;MINFLOAT ) // &#60;=&#62; if(buf[k*col+i]!=0.)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;mul = buf[k*col+i];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;buf[k*col+i] = 0.;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for(int j=i+1; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;buf[k*col+j] -= mul*buf[i*col+j];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for(int j=0; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;resbuf[k*col+j] -= mul*resbuf[i*col+j];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp;}</div><div class="code_line">&nbsp;&nbsp;//Идем вверх</div><div class="code_line">&nbsp;&nbsp;for(int i=row; --i&#62;=0; )</div><div class="code_line">&nbsp;&nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(int k=i; --k&#62;=0; )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if( fabs(buf[k*col+i])&#62;MINFLOAT) // &#60;=&#62; if(buf[k*col+i]!=0.)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;mul = buf[k*col+i];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;buf[k*col+i] = 0.;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for(int j=0; j&#60;col; ++j)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;resbuf[k*col+j] -= mul*resbuf[i*col+j];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp;}</div><div class="code_line">&nbsp;&nbsp;return true;</div><div class="code_line">}</div><div class="code_line">//меняет строки i и j местами</div><div class="code_line">void changerow(double *buf, int i, int j, int col)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp;int sz = sizeof(double)*col;</div><div class="code_line">&nbsp;&nbsp;double *help = new double[sz];</div><div class="code_line">&nbsp;&nbsp;memcpy(help, &amp;buf[i*col], sz);</div><div class="code_line">&nbsp;&nbsp;memcpy(&amp;buf[i*col], &amp;buf[f*col], sz);</div><div class="code_line">&nbsp;&nbsp;memcpy(&amp;buf[f*col], help, sz);</div><div class="code_line">&nbsp;&nbsp;delete[] help;</div><div class="code_line">}</div></ol></div></div></div></div><br>
переделывал &quot;налету&quot; из класса, так что необессудь, ежели чего не так, но логика вроде этой...]]></description>
        <author>Adil</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365999</guid>
        <pubDate>Wed, 26 May 2004 10:20:39 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365999</link>
        <description><![CDATA[AQL: Ну вот смотри сам: начни писать с нахождения определителя. Одно это - уже не самый тривиальный код, просто так с кондачка не выйдет. Дома у меня где то валялись сырцы, но боюсь, уже не откопаю среди многолетних складов проектов (вот что значит, не пользоваться Source Safe или PVCS).]]></description>
        <author>AQL</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365969</guid>
        <pubDate>Wed, 26 May 2004 09:55:07 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365969</link>
        <description><![CDATA[kostya_: На этом сайте слишком заумные алгоритмы, мне бы по простому. Если кто сможет написать сам код , буду при много благодарен.]]></description>
        <author>kostya_</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365920</guid>
        <pubDate>Wed, 26 May 2004 08:59:37 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365920</link>
        <description><![CDATA[AQL: www.programmersheaven.com - много разных исходников и сырцов, в том числе и математических. Вперёд и с поиском. Я бы тебе нашёл, но у меня ограничение на буржуйный траффик.]]></description>
        <author>AQL</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365903</guid>
        <pubDate>Wed, 26 May 2004 08:45:43 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365903</link>
        <description><![CDATA[Vitpan: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <span class='tag-quote__quote-info'>AQL &#064; 26.05.04, 08:17</span><div class='quote '>Что такое определитель, алгебраические дополнения и т.д. рассказывать?</div></div><br>
Не стоит, лучше сразу код :)<br>
<br>
А вообще с этими проблемами mathcad легко справляется.]]></description>
        <author>Vitpan</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365872</guid>
        <pubDate>Wed, 26 May 2004 08:17:12 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365872</link>
        <description><![CDATA[AQL: В общем - простенький алгоритм:<br><br>0) находим определитель первоначальной (прямой) матрицы<br>1) находим матрицу алгебраических дополнений прямой матрицы<br>2) транспонируем её (матрицу алгебраических дополнений)<br>3) делим матрицу алгебраических дополнений на определитель первоначальной матрицы<br>4) наслаждаемся<br><br>Что такое определитель, алгебраические дополнения и т.д. рассказывать?]]></description>
        <author>AQL</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365866</guid>
        <pubDate>Wed, 26 May 2004 08:12:10 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365866</link>
        <description><![CDATA[Adil: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <span class='tag-quote__quote-info'>Sanek &#064; 26.05.04, 11:53</span><div class='quote '><div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>А что, агоритм Гаусса нынче в школе не проходят?</div></div><br>
Смотря где. Мы например проходили.<br>
А как относится алгоритм Гаусса к обратной матрице? :blink:</div></div><br>
Ну ты наверно еще с каким-нибудь гауссом перепутал, плодовитый товарищ был.  :) <br>
А применительно к обращению матрицы это, образно говоря, приводишь матрицу к единичной, синхронно производя такие же действия на единичной матрицой; вот то, что останется от второй и будет обращенная матрица к первой.]]></description>
        <author>Adil</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365843</guid>
        <pubDate>Wed, 26 May 2004 07:53:55 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365843</link>
        <description><![CDATA[Sanek: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>А что, агоритм Гаусса нынче в школе не проходят?</div></div><br>
Смотря где. Мы например проходили.<br>
А как относится алгоритм Гаусса к обратной матрице? :blink:]]></description>
        <author>Sanek</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365545</guid>
        <pubDate>Tue, 25 May 2004 19:22:24 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365545</link>
        <description><![CDATA[Eiden: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '><strong class='tag-b'>Adil</strong>, 25.05.04, 18:46<br>
агоритм Гаусса </div></div><br>
Давно не проходят, вроде. Я не проходил, я выпуск-2003.<br>
<br>
Проблема, очевидно в реализации. <br>
Каким образом задана матрица в файле?]]></description>
        <author>Eiden</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365391</guid>
        <pubDate>Tue, 25 May 2004 14:46:35 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365391</link>
        <description><![CDATA[Adil: А что, агоритм Гаусса нынче в школе не проходят?<br>                           <br>А премножают их так: M(i,j)=SUMM( M1(i,k)*M2(k,j));  сумма по k]]></description>
        <author>Adil</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365368</guid>
        <pubDate>Tue, 25 May 2004 14:07:06 +0000</pubDate>
        <title>Нахождение обратной матрицы</title>
        <link>https://forum.sources.ru/index.php?showtopic=55150&amp;view=findpost&amp;p=365368</link>
        <description><![CDATA[kostya_: Помогите найти обратную матрицу, прочтённую из файла при помощи Scanf,a также проверить путём перемножения матрицы на обратную, чтобы получилась единичная.]]></description>
        <author>kostya_</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      </channel>
      </rss>
	