<?xml version="1.0" encoding="UTF-8" ?>
<feed xml:lang="ja" xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:thr="http://purl.org/syndication/thread/1.0">
  <title type="text">ききひじ</title>
  <subtitle type="html">いろんなことを、思うままに…</subtitle>
  <link rel="self" type="application/atom+xml" href="http://kikihijidarake.blog.shinobi.jp/atom"/>
  <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/"/>
  <updated>2016-05-31T01:25:02+09:00</updated>
  <author><name>ききひじ</name></author>
  <generator uri="//www.ninja.co.jp/blog/" version="0.9">忍者ブログ</generator>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />
  <entry>
    <id>kikihijidarake.blog.shinobi.jp://entry/18</id>
    <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/cpp/opencv_cmake_unbildable" />
    <published>2019-12-13T00:06:51+09:00</published> 
    <updated>2019-12-13T00:06:51+09:00</updated> 
    <category term="C++" label="C++" />
    <title>OpenCVをCMake使ってでビルドするならfind_packageに丸投げするだけではいけない</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<h2>起きたこと</h2>
<p>今まで上手くビルドできていたのに、別プログラムをビルドしようとしたらむっちゃ怒られた。上手く動かないのである。</p>
<h2>環境</h2>
<ul>
<li>Windows 10 64bit</li>
<li>cmake version 3.16.0</li>
<li>MSVC 19.24.28314.0</li>
</ul>
<h2>詳細</h2>
今まで~/testcode/hello/main.cppをビルドしていた。 ここで別の実装を試したくなり、~/testcode/next/main2.cppを実装。ビルドをしようとすると、怒られまくる。具体的には、未定義のコードを参照しようとしているみたいなことを書かれた。（実際のエラーは記録してませんでした。載せられず申し訳ない。） エラーを見る限り明らかに自分が記述したところではなかったが、念のためmain.cppを~/testcode/next/に持ってきてビルドを試みるも結果は変わらず。加えて~/testcode/hello/main.cppのビルドは上手くいくのである。困った。<br />
以下に概略図を示す。汚い手書きですまない。<br />
<img src="//kikihijidarake.blog.shinobi.jp/File/Fig1.PNG" alt="概略図" />
<h2>原因</h2>
<p>cmakeを実行したときの出力とにらめっこしていると、MSVC向けにビルドしているにもかかわらずMinGW用のOpenCVを使おうとしていた。<br />
（私の環境に入っているOpenCVはMSVC用のとMinGW用の2種類がある。）<br />
CmakeLists.txtは全く同じものを利用していたため予想だにしていなかったが、CmakeLists.txt中のfind_package(OpenCV REQUIRED)は状況によって異なる OpenCVConfig.cmake・opencv-config.cmakeを見つけてくるらしい。<br />
（OpenCVConfig.cmakeやopencv-config.cmakeはOpenCVの利用に必要なものを記述したもの...だと思う。）</p>
<h2>解決方法</h2>
<p>CmakeLists.txtに次の一文を追加した。</p>
<code>set(OpenCV_DIR "使いたい方のOpenCVに付属したOpenCVConfig.cmakeやopencv-config.cmakeを含むディレクトリ")</code><br />

<p>つまり、使いたい方のOpenCVに付属したOpenCVConfig.cmakeやopencv-config.cmakeを含むディレクトリを<code>OpenCV_DIR</code>という変数に設定したのである。</p>
<p>これは一度MinGW用のOpenCVを消去してcmakeコマンドを実行したときに出た以下のメッセージをみて知った方法である。</p>
<code><code> Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set</code></code>
<div>&nbsp; "OpenCV_DIR" to a directory containing one of the above files.</div>
<h2>結論</h2>
<p>OpenCVをCMakeからビルドするときには<code>OpenCV_DIR</code>変数を設定することでパッケージの探索先を明示的に示そう。</p>]]> 
    </content>
    <author>
            <name>ききひじ</name>
        </author>
  </entry>
  <entry>
    <id>kikihijidarake.blog.shinobi.jp://entry/17</id>
    <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/tex/tex_install" />
    <published>2019-08-28T08:26:27+09:00</published> 
    <updated>2019-08-28T08:26:27+09:00</updated> 
    <category term="TeX" label="TeX" />
    <title>TeXを入れる</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[パソコンにTeXを導入したときのメモ。<br />

<h2>環境</h2>
<ul>
<li>Windows10</li>
</ul>
<!-- +++++++++++++++++++++++++++++++++++++++++ -->
<h2>TeX Liveのインストール</h2>
<ol>
<li class="lidesign10">ISOイメージのダウンロード。
<div class="indent-2"><a href="http://www.tug.org/texlive/acquire-iso.html">Acquiring TeX Live as an ISO image</a> の download from a nearby CTAN mirrorへ。<br />
texlive2019.iso をクリックしてダウンロードする。<br />
ISOイメージを使う方法以外もある。</div>
</li>
<li class="lidesign10">ダブルクリックによりマウント。</li>
<li class="lidesign10">install-tl-windows.bat をダブルクリック。</li>
<li class="lidesign10">適当に設定してインストール開始。
<ul style="list-style-type: disc;">
<li>インストール先は変更した。<br />
&rarr;プログラミング言語のコンパイラ等を入れているディレクトリと同じ場所にした。<br />
　　雰囲気近そうだからね。</li>
<li>TeX Worksはインストールしない。<br />
　代わりにTexStudioを導入するため。</li>
<li>詳細設定&rarr;コレクションを選択していらないものを除く。
<div class="indent-1">ゲーム組版, 音楽パッケージ</div>
</li>
</ul>
</li>
<li class="lidesign10">インストールの完了を確認してコンピュータの再起動を行う。</li>
<li class="lidesign10">パッケージのアップデート。
<div class="indent-2">「TeX Live 2019」&rarr;「TeX Live Manager」によってアップデートが可能...らしい<br />
私は以下のコマンドを使用<br />
　<em>tlmgr update --self --all</em></div>
</li>
<li class="lidesign10">埋め込む日本語フォントの設定(未)
<div class="indent-2"><a href="https://qiita.com/nijuiti/items/6aa83f35d8f4398ce0a5">ここ</a></div>
</li>
</ol>
<div class="indent-1">参考
<div class="indent-1"><a href="https://texwiki.texjp.org/?TeX%20Live%2FWindows#t70745b0"> TeX Wiki TeX Live / Windows<br />
</a><a href="https://qiita.com/Tats_U_/items/01d48eb70a8b359b0d95">はじめてTeXを使う人が知っておくといいことまとめ</a></div>
</div>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2>TeXstudioのインストール</h2>
<ol>
<li class="lidesign10">ダウンロードする
<div class="indent-2"><a href="https://www.texstudio.org/#download">TeXstudioの公式ダウンロードページ</a>へ行く。<br />
WindowsのType Installerをクリックする。<br />
今回はインストーラを用いた。zip版もあると思われる。</div>
</li>
<li class="lidesign10">実行</li>
<li class="lidesign10">設定<ol>
<li class="lidesign10">ビルド
<div class="indent-1">DVI-&gt;pdfチェーン<br />
LaTeX<br />
PDFビューア<br />
組み込みPDFビューア</div>
</li>
<li class="lidesign10">コマンド（変更したものを以下に示す。元は<a href="https://texwiki.texjp.org/?cmd=read&amp;page=TeXstudio%2F%E8%A8%AD%E5%AE%9A%2FWindows">ここから</a>）
<div class="indent-1">LaTeX
<div class="indent-1">uplatex.exe -no-guess-input-enc -kanji=utf8 -synctex=1 -interaction=nonstopmode %.tex</div>
</div>
<div class="indent-1">PdfLaTeX
<div class="indent-1">pdflatex.exe -synctex=1 -interaction=nonstopmode %.tex</div>
</div>
<div class="indent-1">XeLaTeX
<div class="indent-1">xelatex.exe -synctex=1 -interaction=nonstopmode %.tex</div>
</div>
<div class="indent-1">LuaLaTeX
<div class="indent-1">lualatex.exe -synctex=1 -interaction=nonstopmode %.tex</div>
</div>
<div class="indent-1">外部PDFビューア
<div class="indent-1">"<em>後述のPDFの実行ファイルとパス</em>" -reuse-instance -inverse-search """"<em>TeXstudioの実行ファイルとパス</em>""" """%%f""" -line %%l" "?am.pdf" -forward-search "?c:am.tex" @</div>
</div>
<div class="indent-1">DviPs
<div class="indent-1">ruby.exe -e "cmd='dvips -Ppdf -z -f '+0x22.chr+'?am.dvi'+0x22.chr+' '+0x7c.chr+' '+'convbkmk -u'+' '+0x3e.chr+' '+0x22.chr+'?am.ps'+0x22.chr;system(cmd)"</div>
</div>
<div class="indent-1">BibTeX
<div class="indent-1">upbibtex.exe %</div>
</div>
<div class="indent-1">Biber
<div class="indent-1">biber.exe --bblencoding=utf8 -u -U --output_safechars %</div>
</div>
<div class="indent-1">Makeindex
<div class="indent-1">upmendex.exe %.idx</div>
</div>
<div class="indent-1">Metapost
<div class="indent-1">upmpost.exe -interaction=nonstopmode ?me)</div>
</div>
<div class="indent-1">Asymptote
<div class="indent-1">asy.exe %m*.asy</div>
</div>
<div class="indent-1">Ghostscript
<div class="indent-1">rungs.exe</div>
</div>
<div class="indent-1">Latexmk
<div class="indent-1">latexmk.exe -e "$latex=q/uplatex %%O -kanji=utf8 -no-guess-input-enc -synctex=1 -interaction=nonstopmode %%S/" -e "$bibtex=q/upbibtex %%O %%B/" -e "$biber=q/biber %%O --bblencoding=utf8 -u -U --output_safechars %%B/" -e "$makeindex=q/upmendex %%O -o %%D %%S/" -e "$dvipdf=q/dvipdfmx %%O -o %%D %%S/" -norc -gg -pdfdvi -silent %</div>
</div>
<div class="indent-1">SVN
<div class="indent-1">svn.exe</div>
</div>
<div class="indent-1">SVNADMIN
<div class="indent-1">svnadmin.exe</div>
</div>
</li>
<li class="lidesign10">エディタ
<div class="indent-1">インラインチェックを外す。(日本語文書だとこれが必要らしい)<br />
フォントファミリーは変更した方がいいかもしれない。</div>
</li>
<li class="lidesign10">高度なオプションの表示（左下）にチェックを入れる</li>
<li class="lidesign10">詳細なエディタの設定
<div class="indent-1">「ハック/回避策」&rArr;「最適なディスプレイオプションの選択」のチェックを外し、「描画モード」を「QT」に変更する。
<div class="indent-2">日本語の場合、これをしないとカーソルのずれといった問題に直面することになるらしい。</div>
</div>
<div class="indent-1">一番上にある「行番号を表示」を「すべての行番号」に設定する。
<div class="indent-2">これにより、行番号が表示される。</div>
</div>
</li>
</ol></li>
</ol>
<div class="indent-1">※設定ファイルについて
<div class="indent-1"><a href="https://texwiki.texjp.org/?TeXstudio%2F%E8%A8%AD%E5%AE%9A">ここ</a>のサイトに、各OSにおける設定ファイルの保管場所が記載されている。アンインストール時には、これを消すことも忘れないようにする。</div>
</div>
<div class="indent-1">参考
<div class="indent-1"><a href="https://texwiki.texjp.org/?TeXstudio%2F%E8%A8%AD%E5%AE%9A">TeX Wiki TeXstudio/設定</a><br />
<a href="https://texwiki.texjp.org/?cmd=read&amp;page=TeXstudio%2F%E8%A8%AD%E5%AE%9A%2FWindows">TeX Wiki TeXstudio/設定/Windows</a><br />
<a href="https://www.tsuruo5388.jp/tech-latex-win-setting/#toc3">【環境構築】WindowsでLaTeX2019が使えるようになるまで</a></div>
</div>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2>PDFビューア</h2>
<div class="indent-1">SumatraPDFを使用。<br />
これを使うにはTeXstudioで設定を変更する必要がある。</div>
<br />

<div class="indent-1">参考
<div class="indent-1"><a href="https://qiita.com/Tats_U_/items/01d48eb70a8b359b0d95#pdf%E3%83%93%E3%83%A5%E3%83%BC%E3%82%A2">はじめてTeXを使う人が知っておくといいことまとめ</a></div>
</div>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2>関係ないけれど</h2>
<p>源ノ明朝, 源ノゴシックのJP Subset OTFsを導入した。<br />
　元のデータは取り敢えず/usr/usrname/document/font/の下に置く。</p>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2>Note</h2>
<div class="indent-1">DVI-&gt;pdfチェーン<br />
LaTeX<br />
PDFビューア<br />
組み込みPDFビューア<br />
dvipdfmx<br />
<br />

<p>・tlmgrとは<br />
　TeX Liveのパッケージ管理ソフト</p>
<p>・tlmgrのアクセス先は変更できる。<br />
　参考：http://www.fugenji.org/~thomas/tori-tex/node15.html</p>
<p>・自分で処理をすることもできる<br />
　　platex hoge.tex<br />
　　dvipdfmx hoge.dvi<br />
　のような手順で hoge.tex から hoge.pdfを作ることができる。</p>
<p>・パッケージの文書（技術文書）を表示することができる。<br />
　　texdoc <em>パッケージ名</em><br />
　参考：<a href="http://www.fugenji.org/~thomas/tori-tex/node21.html">ここ</a></p>
<p>・\documentclass[a4j]{jsarticle}　が上手くいかない。<br />
　&rarr;\documentclass[uplatex, a4j]{jsarticle}　にする。<br />
　　jsarticleなどは、そのままではupLaTeXで使うことができない。<br />
　　参考:<a href="https://texwiki.texjp.org/?%E3%82%88%E3%81%8F%E3%81%82%E3%82%8B%E8%B3%AA%E5%95%8F#p2c0bcc3" title="">ここ<br />
</a> 　&rarr;或いは \documentclass[a4j]{ujarticle}　にする。</p>
<p>・LaTeXドキュメントをHTML二変換したい場合<br />
　<a href="https://texwiki.texjp.org/?LaTeX2HTML">ここ</a>とか使えそう。</p>
<br />
便利<br />
<a href="https://qiita.com/zr_tex8r/items/a924be192ecea7e6bbe4">https://qiita.com/zr_tex8r/items/a924be192ecea7e6bbe4<br />
</a></div>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<h2>Linuxに入れたくなった時のために</h2>
<div class="indent-1">以下のリンクを(片っ端から)参照<br />
https://user.ecc.u-tokyo.ac.jp/users/user-15826/wiki/?TeX/Install</div>]]> 
    </content>
    <author>
            <name>ききひじ</name>
        </author>
  </entry>
  <entry>
    <id>kikihijidarake.blog.shinobi.jp://entry/14</id>
    <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/compro/%E4%BB%8A%E5%BE%8C%E8%AA%BF%E6%9F%BB%E3%83%BB%E7%A0%94%E7%A9%B6%E3%81%99%E3%82%8B%E3%81%93%E3%81%A8" />
    <published>2019-03-24T20:51:45+09:00</published> 
    <updated>2019-03-24T20:51:45+09:00</updated> 
    <category term="競技プログラミング" label="競技プログラミング" />
    <title>今後調査・研究すること</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[完全なる備忘録<br />
下記について、オヌヌメのサイトなどあればコメントで教えてください。<br />
<br />
・重複の除去<br />
<a href="https://qiita.com/ysk24ok/items/30ae72f4f1060b088588">https://qiita.com/ysk24ok/items/30ae72f4f1060b088588<br />
<br />
</a>・std::set（上とも関連）<br />
http://vivi.dyndns.org/tech/cpp/set.html<br />
<br />
・Union-Find木<br />
<a href="https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396">https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396</a><br />
<br />
・<a href="http://vivi.dyndns.org/tech/cpp/set.html"></a>]]> 
    </content>
    <author>
            <name>ききひじ</name>
        </author>
  </entry>
  <entry>
    <id>kikihijidarake.blog.shinobi.jp://entry/12</id>
    <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/compro/abstractabc001010" />
    <published>2019-03-21T01:55:27+09:00</published> 
    <updated>2019-03-21T01:55:27+09:00</updated> 
    <category term="競技プログラミング" label="競技プログラミング" />
    <title>ABC001-010まとめ</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<p>AtCoderBeginnerContestの各問題におけるミソを<strong><span style="text-decoration: underline;">自分用に</span></strong>まとめた記事。<br />
その001-010。<br />
リンク先はそのミソについてまとめられた（まとめた）記事になっています。</p>
<br />

<h3><a href="https://atcoder.jp/contests/abc001/" title="" target="_blank">ABC001</a></h3>
<p style="margin-left: 10px;">A問題　なし</p>
<p style="margin-left: 10px;">B問題　なし</p>
<p style="margin-left: 10px;">C問題<br />
<span style="margin-left: 10px;">小数の計算誤差。</span><br />
<span style="margin-left: 10px;"><a href="http://kikihijidarake.blog.shinobi.jp/nocategory/avoidcalcerror" title="" target="_blank">http://kikihijidarake.blog.shinobi.jp/nocategory/avoidcalcerror</a></span><br />
<span style="margin-left: 10px;">一般には私がまとめたのより、こちらのサイトの方が詳しいし良いかも。</span><span style="margin-left: 10px;"><a href="http://d.hatena.ne.jp/komiyam/20111210/1323503019" title="" target="_blank">http://d.hatena.ne.jp/komiyam/20111210/1323503019</a></span></p>
<p style="margin-left: 10px;">D問題</p>
<br />

<h3><a href="https://atcoder.jp/contests/abc002/" title="" target="_blank">ABC002</a></h3>
<p style="margin-left: 10px;">A問題　なし</p>
<p style="margin-left: 10px;">B問題　なし</p>
<p style="margin-left: 10px;">C問題<br />
<span style="margin-left: 10px;">小数の計算誤差。</span><br />
<span style="margin-left: 10px;">同上</span></p>
<p style="margin-left: 10px;">D問題</p>
<br />

<h3><a href="https://atcoder.jp/contests/abc003/" title="" target="_blank">ABC003</a></h3>
<p style="margin-left: 10px;">A問題<br />
<span style="margin-left: 10px;">計算順序とかもっといい方法があった。</span><br />
<span style="margin-left: 10px;">詳細はいずれ。（書かないかも）</span></p>
<p style="margin-left: 10px;">B問題<br />
<span style="margin-left: 10px;">別解：文字に点数をつけて、その合計点を見ることで条件を満たすか否かを判別する方法。</span><br />
<span style="margin-left: 10px;">文字と点数の結びつけは連想配列で。C++ならstd::mapとか。</span> <br />
<span style="margin-left: 10px;">&rarr;連想配列の詳細&nbsp;<a href="http://vivi.dyndns.org/tech/cpp/map.html" title="" target="_blank">http://vivi.dyndns.org/tech/cpp/map.html</a></span><br />
<span style="margin-left: 10px;">詳細はいずれ。（書かないかも）</span></p>
<p style="margin-left: 10px;">C問題<br />
<span style="margin-left: 10px;">組み合わせが膨大な問題に対してどう取り組むか。</span><br />
<span style="margin-left: 10px;">詳細はいずれ。（書かないかも）</span></p>
<p style="margin-left: 10px;">D問題</p>
<br />

<h3><a href="https://atcoder.jp/contests/abc004/" title="" target="_blank">ABC004</a></h3>
<p style="margin-left: 10px;">A問題　なし</p>
<p style="margin-left: 10px;">B問題<br />
<span style="margin-left: 10px;">マスをどうやって回転させるか。</span><br />
<span style="margin-left: 10px;">&rarr;c[i][j]とc[3-i][3-j]をswapすればよい。</span></p>
<p style="margin-left: 10px;">C問題<br />
<span style="margin-left: 10px;">膨大な計算をどう削減するか。</span><br />
<span style="margin-left: 10px;">&rarr;今回は繰り返し（規則性）の発見。</span><br />
<span style="margin-left: 10px;">&rarr;やっている計算も同じようなことを繰り返しているだけだしね。</span><br />
<span style="margin-left: 10px;">詳細はなし。</span></p>
<p style="margin-left: 10px;">D問題</p>
<br />

<h3><a href="https://atcoder.jp/contests/abc005/" title="" target="_blank">ABC005</a></h3>
<p style="margin-left: 10px;">A問題　なし</p>
<p style="margin-left: 10px;">B問題　ソートするか入力段階でmin値を更新していくか。</p>
<p style="margin-left: 10px;">C問題　別解の二部グラフってなに。調べたら追記。</p>
<p style="margin-left: 10px;">D問題</p>
<br />

<h3><a href="https://atcoder.jp/contests/abc006/" title="" target="_blank">ABC006</a></h3>
<p style="margin-left: 10px;">A問題　なし</p>
<p style="margin-left: 10px;">B問題　なし</p>
<p style="margin-left: 10px;">C問題　1変数の固定とか、3変数のうち既に求めた2変数を用いて残りの1変数を導出するとか。</p>
<p style="margin-left: 10px;">D問題</p>
<br />

<h3><a href="https://atcoder.jp/contests/abc007" title="" target="_blank">ABC007</a></h3>
<p style="margin-left: 10px;">A問題　なし</p>
<p style="margin-left: 10px;">B問題　なし</p>
<p style="margin-left: 10px;">C問題　幅優先探索の例題</p>
<p style="margin-left: 10px;">D問題</p>
<br />

<h3><a href="https://atcoder.jp/contests/abc008" title="" target="_blank">ABC008</a></h3>
<p style="margin-left: 10px;">A問題　なし</p>
<p style="margin-left: 10px;">B問題　なし</p>
<p style="margin-left: 10px;">C問題</p>
<p style="margin-left: 10px;">D問題</p>
<br />

<h3><a href="https://atcoder.jp/contests/abc009" title="" target="_blank">ABC009</a></h3>
<p style="margin-left: 10px;">A問題　なし</p>
<p style="margin-left: 10px;">B問題　降順ソートのやり方<br />
<a href="http://kikihijidarake.blog.shinobi.jp/Entry/8/" title="" target="_blank">http://kikihijidarake.blog.shinobi.jp/Entry/8/</a></p>
<p style="margin-left: 10px;">C問題</p>
<p style="margin-left: 10px;">D問題</p>
<br />

<h3><a href="https://atcoder.jp/contests/abc010" title="" target="_blank">ABC010</a></h3>
<p style="margin-left: 10px;">A問題　なし</p>
<p style="margin-left: 10px;">B問題　なし</p>
<p style="margin-left: 10px;">C問題<br />
<span style="margin-left: 10px;">小数の計算誤差。</span><br />
<span style="margin-left: 10px;">ABC001 C問題と同じ</span></p>
<p style="margin-left: 10px;">D問題</p>
<p style="margin-left: 10px;"><span style="margin-left: 10px;"></span><br />
<span style="margin-left: 10px;"></span></p>]]> 
    </content>
    <author>
            <name>ききひじ</name>
        </author>
  </entry>
  <entry>
    <id>kikihijidarake.blog.shinobi.jp://entry/10</id>
    <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/compro/avoidcalcerror" />
    <published>2019-03-20T23:16:26+09:00</published> 
    <updated>2019-03-20T23:16:26+09:00</updated> 
    <category term="競技プログラミング" label="競技プログラミング" />
    <title>小数計算の誤差を回避する</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[ききひじの競プロ備忘録
<p>割り算の結果が小数になる場合、その誤差が時に問題を生じさせる。<br />
特に比較をするときなどは顕著だろう。<br />
その解決策である。<br />
<br />
因みに私は記事を書いてなおよくわかっていない。</p>
<h2>回避策1：少しだけ小さい数を足す</h2>
<p><span style="text-decoration: underline;">割られる数が整数などの場合</span>、計算結果に、例えば0.00001のような小さめの値を足すという方法がある。</p>
<pre><code>double ans = 241 / 60 + 0.00001;</code></pre>
<br />

<p>「少しだけ」が曖昧なので、妥当な数字がどれくらいかを考えるのは難しい気がする。<br />
また割られる数が小数以下の細かい数字の場合、この方法をとることが出来ない。</p>
<br />

<h2>回避策2：10のn乗倍してから、整数として計算する。</h2>
<p>整数xを整数yで割る。このとき、商を10^-nの精度で求めたいとする。<br />
解決策2では、xを先に10^n倍してyで割るのだ。そして計算結果を10^-n倍すればよい。</p>
<p>もし計算結果をそのまま出力するとか、文字にするのならば10^-n倍しないことも可能だろう。こうすると完全にずれはなくなる&hellip;気がする。</p>
<pre><code>// n = 1, y=2 のとき
const int a = 何かしらの値1
const int b = 何かしらの値2

cin&gt;&gt;x;
x = x * 10 / 2;
cout&lt;&lt; x / 10 &lt;&lt; '.' &lt;&lt; x % 10 &lt;&lt; flush;
</code></pre>
<br />

<p>また、計算が続くのならば、すべての計算が終わった段階で10^-n倍するとよいかもしれない。 この方法で注意すべきは、変数のオーバーフローである。特に計算が長く続き、かつ最後に10^-n倍をする場合、その計算途中で桁が溢れる危険があるので使う際には留意されたし。</p>
<br />

<h2>回避策3：そもそも計算しない</h2>
<p>そもそも小数を扱わなければいけないような計算をしなければいい。</p>
<p>例えば、入力xについて、xを７で割った商で条件分岐する場合を考える。 <br />
このとき、境目となる値を先に7倍し、7倍された値とxを比較すればよいのだ。</p>
before
<pre><code>// a &gt; b
const double a = 何かしらの値1
const double b = 何かしらの値2

cin&gt;&gt;x;
double quotient = x/7;
if(quotient &gt; a){
  //何かしらの処理
}
else if(quotient &gt; b){
  //何かしらの処理
}
else{
  //何かしらの処理
}</code></pre>
<br />
after AやBは可能なら先に自分で計算をしておくとよりよい（のだろうか）。<br />

<pre><code>// a &gt; b
const double A = 何かしらの値1*7
const double B = 何かしらの値2*7

cin&gt;&gt;x;
if(x &gt; A){
  //何かしらの処理
}
else if(x &gt; B){
  //何かしらの処理
}
else{
  //何かしらの処理
}</code></pre>]]> 
    </content>
    <author>
            <name>ききひじ</name>
        </author>
  </entry>
  <entry>
    <id>kikihijidarake.blog.shinobi.jp://entry/9</id>
    <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/python/python_pip_error_eng" />
    <published>2019-02-11T03:30:20+09:00</published> 
    <updated>2019-02-11T03:30:20+09:00</updated> 
    <category term="Python" label="Python" />
    <title>Fatal error in launcher: Unable to create process using &quot;&quot; (English)</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[日本語記事は<span style="color: #3366ff;"><a href="http://kikihijidarake.blog.shinobi.jp/python/python__pip_error" title="日本語版" target="_self"><span style="color: #3366ff;">こちら</span></a></span><br />
I could not run some pip commands...
<h2>・Caution</h2>
<p>I am not professional, so what I will tell you may be incorrect. I recommend you to check what you read are really correct comparing with other sources (and if you find any mistakes, please tell me about it).</p>
<h2>・Background</h2>
<p>I was installing Python and pip to my desktop PC. First I installed Python3. After a short time, I realized that Python2 were also needed in my use, so I installed it.</p>
<p>Unfortunately, after that, some articles on the Internet says that if not install Python2 before installation of Python3, I cannot control Python version. (Perhaps, there are other ways.)</p>
<p>Therefore, I uninstalled Python2 and Python3 through Control Panel, and reinstalled in the order of Python2 and Python3. In this way, I succesed installation of them.</p>
<p>However, when I tried to run pip command via command prompt to make sure that installation was succeed, some pip command did not work and the following error message was shown.<br />
　　<em>Fatal error in launcher: Unable to create process using "" ""　　</em><br />
This message was displayed when I use the command like<br />
　　pip <em>"something"</em><br />
If pip command work correctly, it is predicted that pip3 (pip of Python3) will run, but it didn't, though commands like<br />
　　py -m pip <em>"something"</em><br />
worked...</p>
<h2>・Environment</h2>
<p>Windows10 Pro<br />
Python3.7.1<br />
python2.7.15</p>
<h2>・What I Did.</h2>
<p>First, I made sure that the path was set correctly. If you have never checked the path, you should do that referencing other article.</p>
<p>Second, I checked the path in Python and I confirmed that "bad path" did not exited. (*1) <br />
<span style="color: #c0c0c0;" data-mce-mark="1">I heard there is a path in Python, but I do not know well about it. </span></p>
<p>Moreover, I tried to update pip using the command below.<br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<em>py -m pip install -U pip　</em><br />
To my disappointment, it told me that the version of pip was latest.</p>
<p>Finally, I did reinstall Python further again and I did it&nbsp; strictly. It solved the problem...<br />
I uninstalled both Pythons and deleted all remaining files exited in the directory where Python were. In addition, I also deleted data related to pip which were in C:\Users\"UserName"\AppData\Local. After that, I install python2 followed by python3.</p>
<h3>*1</h3>
<p>I do not think that checking it has meaning, but I write how did I check it just in case.<br />
Via command prompt, I started Python and typed the next codes.</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;C:\******&gt; python<br />
&nbsp; &nbsp; &nbsp; &nbsp;&gt;&gt;&gt; import sys<br />
&nbsp; &nbsp; &nbsp; &nbsp;&gt;&gt;&gt; sys.path</p>
<p>After that, some directories were shown and I checked them.</p>]]> 
    </content>
    <author>
            <name>ききひじ</name>
        </author>
  </entry>
  <entry>
    <id>kikihijidarake.blog.shinobi.jp://entry/8</id>
    <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/compro/sortanddescendingsort" />
    <published>2019-02-10T16:45:39+09:00</published> 
    <updated>2019-02-10T16:45:39+09:00</updated> 
    <category term="競技プログラミング" label="競技プログラミング" />
    <title>ソートと降順（逆順）ソート　~~ C++ ~~</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[ききひじの競プロ備忘録
<h2>・ソート</h2>
必要なヘッダファイルは<span style="text-decoration: underline;">&lt;algorithm&gt;</span> <br />
以下の方法で、データを昇順（小&rarr;大）にすることができる。<br />
処理としてはクイックソートを行っているはず。 <br />
例えばvectorをソートするならば、 <br />
<br />

<pre><code>#include &lt;algorithm&gt;
#include &lt;iostream&gt;

int main() {
  vector&lt;int&gt; A(5);
  for (int i = 0; i &lt; 5; ++i) {
    cin&gt;&gt;A[i];
  }

  //肝心のソート部
  sort(A.begin(), A.end());
  for (int i = 0; i &lt; 5; ++i) {
    cout&lt;&lt;A[i]&lt;&lt;" ";
  }
  cout&lt;&lt;endl;
}</code></pre>
<br />
<span> 例えば上記のコードで<br />
　　7 3 4 1 9<br />
と入力すれば、<br />
　　1 3 4 7 9<br />
と結果が出力される。<br />
<br />
</span>
<h2>・降順ソート</h2>
先のソートでは昇順でソートされた。<br />
これを降順（大&rarr;小）でソートするにはどうすればいいか。<br />
ヘッダファイルは上記の&lt;algorithm&gt;に加えて<span style="text-decoration: underline;">&lt;functional&gt;</span>も必要となる。<br />

<pre><code>#include &lt;algorithm&gt;
#include &lt;functional&gt;  //これが必要
#include &lt;iostream&gt;

int main() {
  vector&lt;int&gt; A(5);
  for (int i = 0; i &lt; 5; ++i) {
    cin&gt;&gt;A[i];
  }

  //肝心のソート部
  sort(A.begin(), A.end(), greater&lt;int&gt;());
<br />

for (int i = 0; i &lt; 5; ++i) {
    cout&lt;&lt;A[i]&lt;&lt;" ";
  }
  cout&lt;&lt;endl;
}</code></pre>
<br />
<span> 例えば上記のコードで<br />
　　7 3 4 1 9<br />
と入力すれば、<br />
　　9 7 4 3 1<br />
と結果が出力される。<br />
</span> <br />

<h4>降順ソート別解</h4>
<span> 以下の方法でも逆順ソートは達成できる。<br />
またこの場合は&lt;functional&gt;は不要となる。<br />
ただ、実行速度はこちらの方が劣るとか。 </span>
<pre><code>#include &lt;algorithm&gt;
#include &lt;iostream&gt;

int main() {
  vector&lt;int&gt; A(5);
  for (int i = 0; i &lt; 5; ++i) {
    cin&gt;&gt;A[i];
  }

  //肝心のソート部
  sort(A.rbegin(), A.rend());<br />


  for (int i = 0; i &lt; 5; ++i) {
    cout&lt;&lt;A[i]&lt;&lt;" ";
  }
  cout&lt;&lt;endl;
}</code></pre>
<br />

<h3>・因みに&hellip;</h3>
<sapn> std::sort() <br />
std::greater&lt;Type&gt;()<br />
とstdです。</sapn>]]> 
    </content>
    <author>
            <name>ききひじ</name>
        </author>
  </entry>
  <entry>
    <id>kikihijidarake.blog.shinobi.jp://entry/6</id>
    <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/ubuntu/install_ubuntu_18_04_1_lts_note" />
    <published>2019-01-11T20:10:34+09:00</published> 
    <updated>2019-01-11T20:10:34+09:00</updated> 
    <category term="Ubuntu" label="Ubuntu" />
    <title>Ubuntu 18.04.1 LTSのインストール（Note）</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<p>※やったことを備忘録的に列挙していくページです。<br />
　わかりやすさは他のwebページの方が優れているかと思います。うっかりこのページにたどり着いた方は、最下部の参考にあるサイト等を参照した方がわかりやすいでしょう。</p>
<h2>用意したもの</h2>
<ul>
<li>ノートPC</li>
<li>USB</li>
</ul>
<h2>やったこと</h2>
①「Ubuntu 18.04.1 LTS」のダウンロード<br />
　<a href="http://jp.releases.ubuntu.com/18.04.1/" title="" target="_blank">http://jp.releases.ubuntu.com/18.04.1/</a>&nbsp;より<br />
　ノートPCに導入予定のため、デスクトップ版をダウンロード<br />
<br />
<br />
②「Rufus」をダウンロード<br />
　<a href="https://rufus.ie/" title="" target="_blank">https://rufus.ie/</a>&nbsp;より<br />
　「Rufus」は、
<blockquote><em>起動可能なISOファイル（Windows、Linux、UEFIなど）からUSBインストールメディアを作成するとき </em><br />
出典：&nbsp;<a href="https://rufus.ie/" title="" target="_blank">https://rufus.ie/</a></blockquote>
　などに使えるソフト。<br />
<br />
<br />
③上記ソフトを利用し、用意したUSBをUbuntuのインストールメディアにする。<br />
　ソフトは直感的に使えた。<br />
<br />
<br />
④Ubuntuをインストールするパソコンに、③で作成したUSBインストールメディアを指し、電源を入れて<span style="text-decoration: line-through;">BIOSかUEFIを起動。<br />
</span><span style="text-decoration-line: line-through;">今回用いたPCではF2キーを連打。</span><br />

<p style="padding-left: 1em;">&rarr;BIOSの起動は間に合わなかったorz。こんな時は、再度コンピューターの電源を落として再起動させればもう一度挑戦できる。<br />
<br />
&rarr;もともと入っていたWindows 7が起動すると予想したが、普通にUSBからUbuntuが起動。おそらくBIOSの設定で、OSはHDDよりもUSBメディアを優先するようになっていたのだろう。</p>
<br />
<br />
⑤「ようこそ」画面の設定<br />
・言語は「日本語」を選択<br />
・「Ubuntuをインストール」をクリック<br />
<br />
<br />
⑥「キーボードレイアウト」の設定<br />
・左右どちらも「日本語」を設定<br />
　（日本語キーボードを使っていない場合は環境に合わせる？）<br />
<br />
<br />
⑦「無線」の設定<br />
・「wi-fiネットワークに今すぐには接続しない」を選択<br />
　有線でつないでいるから<br />
<span style="text-decoration: line-through;">　（有線でつないでいなくても、とりあえずこの選択でOK?）</span>
<p style="padding-left: 1em;">&rarr;⑧でUbuntuのインストール中にアップデートをダウンロードする」を選ぶならwi-fiの設定はした方がいいかも</p>
<br />
<br />
<br />
⑧「アップデートと他のソフトウェア」の設定<br />
・「最小インストール」を選択<br />
　　自分の用途を考えると、不要なソフトはなるべく省きたい<br />
・「Ubuntuのインストール中にアップデートをダウンロードする」をチェック<br />
　　自分でやるのは面倒くさいからね<br />
・「グラフィックスとwi-fiハードウェアと&hellip;」をチェック<br />
<br />
<br />
⑨「インストールの種類」の設定<br />
・「ディスクを消去してUbuntuをインストール」を選択<br />
　　既に入っているWindows 7は消去するつもりのため。<br />
・「安全のため新しいUbuntuのインストールを暗号化する」のチェックは入れない<br />
　　後から出来そう<br />
・「新しいUbuntuのインストールにLVMを使用する」<br />
　　同上<br />
<br />
<br />
⑩インストールが終わるのを待ち再起動<br />
<br />
<br />
<br />
以上<br />
ソフトのインストール等は別の記事で<br />
<br />
<br />

<h2>参考</h2>
Linux Fan (2018/08/27) :&nbsp;Ubuntu 18.04 LTSインストールガイド【スクリーンショットつき解説】<br />
https://linuxfan.info/ubuntu-18-04-install-guide (2019-01-11 参照)<br />
kledgeb (2018/4/30) :Ubuntu 18.04 インストール準備 その1 - Ubuntu 18.04をインストールする前に・Ubuntuのライブメディアを作成してUbuntuを起動する<br />
https://kledgeb.blogspot.com/2018/04/ubuntu-1804-1-ubuntu-1804ubuntuubuntu.html&nbsp;(2019-01-11 参照)&nbsp;<br />
<br />
<span style="text-decoration: line-through;"><br />
</span>]]> 
    </content>
    <author>
            <name>ききひじ</name>
        </author>
  </entry>
  <entry>
    <id>kikihijidarake.blog.shinobi.jp://entry/4</id>
    <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/python/python__pip_error" />
    <published>2018-10-22T01:15:09+09:00</published> 
    <updated>2018-10-22T01:15:09+09:00</updated> 
    <category term="Python" label="Python" />
    <title>Fatal error in launcher: Unable to create process using &quot;&quot;</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[The same article written in English is <span style="color: #3366ff;"><a href="http://kikihijidarake.blog.shinobi.jp/python/python_pip_error_eng" title="English ver." target="_self"><span style="color: #3366ff;">here</span></a></span>.<br />
pipの実行がうまくいかない
<h2>・症状</h2>
<p>Pythonとpipのインストール時に、これらがうまくできたかを確認するため、コマンドプロンプトからそれぞれのコマンドを実行して確認していた。</p>
<p>だがpipコマンドの実行がうまくいかない。下記のようなエラーが出てしまうのだ。</p>
<p>　　Fatal error in launcher: Unable to create process using "" ""　　</p>
<p>これを解決したい。</p>
<h2>・諸注意</h2>
<p>素人が備忘録的に書いている記事です。必ずしも正しいわけではないので、鵜呑みにせずよく確認してください。</p>
<h2>・環境</h2>
<p>Windows10 Pro<br />
Python3.7.1<br />
python2.7.15</p>
<h2>・背景</h2>
<p>諸事情により、私は自宅のデスクトップパソコンへPythonを入れることになった。それもPython2とPython3の両方である。</p>
<p>はじめにPython3をいれた...のだが、ここでPython2を入れる必要があることに気が付く。そこでPython2を入れた。だがどうもネットで検索していると、先にPython2を入れ、そのあとPython3を入れないとうまくバージョン管理ができないらしい。（他にやりようはあるのかもしれないが。）<br />
そこでそれぞれをコントロールパネルからアンインストール。Python2-&gt;Python3の順にインストールをし直したのだ。こうしてPython2とPython3はうまくインストールできたのである。だがpipコマンドの確認段階でつまずいてしまった。<br />
　　pip コマンド　<br />
等の形で実行されるはずの、<span style="text-decoration: underline;">Python3の</span>pipがうまく実行できないのである。<br />
　　py -m pip コマンド　<br />
では実行できるのに...。</p>
<h2>・解決まで</h2>
<p>まず初めに、正しくPathが通っているかを調べ、問題がないことを確認した。人によってはこの段階で原因を発見できると思うが、詳しい説明は他のブログやサイトを参照してほしい。</p>
<p>次にPython内のPathである。<span style="text-decoration: underline;">存在するらしい</span>。これを調べることに意味はなさそうだが、余計なところにPathが通っていないことを確認した。（注１）</p>
<p>またpipのアップデートも試みた。<br />
　　py -m pip install -U pip　<br />
である。だが最新版であるという結果に。</p>
<p>そして最後にやったのがPython3の再インストールである。</p>
<p>まずPythonをアンインストールする。そして、もともとPythonがインストールされていたディレクトリ以下に残っているファイルを全て消去。さらにC:\Users\ユーザ名\AppData\Local以下にあるpipのデータも消去しておいた。その上でPythonを再度インストールするのである。私の場合はこれで解決した。</p>
<h3>注１</h3>
<p>これに関しては的外れだと思うが、一応私が確認した方法について。<br />
まず　Python　でPythonを実行。　import sys　と　sys.path　で出力されたディレクトリを確認した。</p>]]> 
    </content>
    <author>
            <name>ききひじ</name>
        </author>
  </entry>
  <entry>
    <id>kikihijidarake.blog.shinobi.jp://entry/3</id>
    <link rel="alternate" type="text/html" href="http://kikihijidarake.blog.shinobi.jp/electronicwork/avr_gcc_bitshift_limitation" />
    <published>2016-08-26T21:25:15+09:00</published> 
    <updated>2016-08-26T21:25:15+09:00</updated> 
    <category term="電子工作" label="電子工作" />
    <title>C言語（avr-gcc下）のシフトの上限について</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[------------------------------------------------------------------------------------------------------------------<br />

<h3>- 結論 -<br />
C言語(avr-gcc)のシフトの上限は15まで</h3>
<h4>※他の言語, コンパイラは不明、c++やjsでは31までという記述を確認<br />
※AVR8bitマイコンです</h4>
------------------------------------------------------------------------------------------------------------------<br />
<br />
注、ソースはstack overflow。以前調べた際に見つけたページのリンクが見つからず&hellip;申し訳ない。<br />
<br />

<p>日本語サイトでこの事に触れているサイトが見つからなかったので一応ここに&hellip;<br />
常識過ぎて書かれていないなんてことはないと信じたい。</p>
<br />

<p>以前とある理由でめちゃくちゃシフトしたくなることがありまして、以下の様な感じのプログラム <br />
<br />
unsigned long hoge;<br />
hoge |= 1&lt;&lt;24;<br />
<br />
を書いたわけですが、「変数に対して値が大きすぎる」みたいな警告（エラーだったか）が出てしまいまい、実際にうまくいきませんでした。<br />
変数の大きさはコンパイラによって変わったりするものなので、念の為にlong型の大きさを確認してみましたが4byteで問題ない。で、調べたわけですがどうやらシフト出来る大きさにも上限があるらしく、その上限がavr-gccの場合「15」だそうです。<br />
まあそんなわけで私は実装の仕方を変えて解決したわけですが、シフト数を変数などで指定する場合はうっかり上限を超えてしまったりするのでお気をつけを。特に変数で上限を超えてしまった場合などはそのことに気が付きにくいと思うので。</p>]]> 
    </content>
    <author>
            <name>ききひじ</name>
        </author>
  </entry>
</feed>