gschur() was declared obsolete in Scilab 4, now removed
[scilab.git] / scilab / modules / functions / help / ja_JP / overloading.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
5  * Copyright (C) INRIA
6  *
7  * Copyright (C) 2012 - 2016 - Scilab Enterprises
8  *
9  * This file is hereby licensed under the terms of the GNU GPL v2.0,
10  * pursuant to article 5.3.4 of the CeCILL v.2.1.
11  * This file was originally licensed under the terms of the CeCILL v2.1,
12  * and continues to be available under such terms.
13  * For more information, see the COPYING file which you should have received
14  * along with this program.
15  *
16  -->
17
18 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="overloading" xml:lang="ja">
19     
20     <refnamediv>
21         
22         <refname>overloading</refname>
23         
24         <refpurpose>表示,関数および演算子オーバーロード機能</refpurpose>
25         
26     </refnamediv>
27     
28     <refsection>
29         
30         <title>説明</title>
31         
32         <para>
33             
34             Scilabにおいては, 変数表示, 関数および演算子は
35             
36             関数(Scilabコードまたはプリミティブ)により新規オブジェクト用に
37             
38             定義することができます.
39             
40         </para>
41         
42         <variablelist>
43             
44             <varlistentry>
45                 
46                 <term>表示</term>
47                 
48                 <listitem>
49                     
50                     <para>
51                         
52                         <literal>tlist</literal>により定義される 新規オブジェクトの表示は,
53                         
54                         オーバーロードすることができます
55                         
56                         (デフォルトの表示は<literal>list</literal>の出力に似ています).
57                         
58                         オーバーロード関数は入力引数を1つとし,出力引数を持たない必要があります.
59                         
60                         その関数の名前は,<literal>%&lt;tlist_type&gt;_p</literal>のように 作成します. 
61                         
62                         ただし,
63                         
64                         <literal>%&lt;tlist_type&gt;</literal> は,
65                         
66                         <literal>tlist</literal>型の要素の最初のエントリを
67                         
68                         最初の9文字に丸めたものを意味します.
69                         
70                     </para>
71                     
72                 </listitem>
73                 
74             </varlistentry>
75             
76             <varlistentry>
77                 
78                 <term>演算子</term>
79                 
80                 <listitem>
81                     
82                     <para>
83                         
84                         指定したオペランド型について定義されていない各演算子を定義することができます.
85                         
86                         オーバーロード関数は入力引数を1つ,オペランドの数に基づき 1個または
87                         
88                         2個の入力を有する必要があります.
89                         
90                         関数名は以下のように作成されます:
91                         
92                     </para>
93                     
94                 </listitem>
95                 
96             </varlistentry>
97             
98         </variablelist>
99         
100         <para>2項演算子の場合:
101             
102             <literal>%&lt;first_operand_type&gt;_&lt;op_code&gt;_&lt;second_operand_type&gt;</literal>
103             
104         </para>
105         
106         <para>単項演算子の場合:
107             
108             <literal>%&lt;operand_type&gt;_&lt;op_code&gt;</literal>
109             
110         </para>
111         
112         <para>n項演算子の展開および挿入は以下のように記述されます.</para>
113         
114         <warning>
115             
116             <function>typename</function>関数に登録された型のみが
117             
118             オーバーロードマクロの中で使用できることに注意してください.
119             
120         </warning>
121         
122         <para>
123             
124             <literal>&lt;operand_type&gt;</literal>,
125             
126             <literal>&lt;first_operand_type&gt;</literal>,
127             
128             <literal>&lt;second_operand_type&gt;</literal> は, 
129             
130             以下のテーブルに記述された各データ型に関連する文字シーケンスです:
131             
132         </para>
133         
134         <informaltable border="1">
135             
136             <tr>
137                 
138                 <td>データ型</td>
139                 
140                 <td>文字コード</td>
141                 
142                 <td>typeof</td>
143                 
144                 <td>コメント</td>
145                 
146             </tr>
147             
148             <tr>
149                 
150                 <td>double行列</td>
151                 
152                 <td>
153                     
154                     <literal>s</literal>
155                     
156                 </td>
157                 
158                 <td>
159                     
160                     <literal>定数</literal>
161                     
162                 </td>
163                 
164                 <td/>
165                 
166             </tr>
167             
168             <tr>
169                 
170                 <td>多項式行列</td>
171                 
172                 <td>
173                     
174                     <literal>p</literal>
175                     
176                 </td>
177                 
178                 <td>
179                     
180                     <literal>多項式</literal>
181                     
182                 </td>
183                 
184                 <td/>
185                 
186             </tr>
187             
188             <tr>
189                 
190                 <td>論理値行列</td>
191                 
192                 <td>
193                     
194                     <literal>b</literal>
195                     
196                 </td>
197                 
198                 <td>
199                     
200                     <literal>論理値</literal>
201                     
202                 </td>
203                 
204                 <td/>
205                 
206             </tr>
207             
208             <tr>
209                 
210                 <td>疎行列</td>
211                 
212                 <td>
213                     
214                     <literal>sp</literal>
215                     
216                 </td>
217                 
218                 <td>
219                     
220                     <literal>疎行列</literal>
221                     
222                 </td>
223                 
224                 <td/>
225                 
226             </tr>
227             
228             <tr>
229                 
230                 <td>論理値疎行列</td>
231                 
232                 <td>
233                     
234                     <literal>spb</literal>
235                     
236                 </td>
237                 
238                 <td>
239                     
240                     <literal>論理値疎行列</literal>
241                     
242                 </td>
243                 
244                 <td/>
245                 
246             </tr>
247             
248             <tr>
249                 
250                 <td>Matlab 疎行列</td>
251                 
252                 <td>
253                     
254                     <literal>msp</literal>
255                     
256                 </td>
257                 
258                 <td>
259                     
260                     <literal>Matlab疎行列</literal>
261                     
262                 </td>
263                 
264                 <td/>
265                 
266             </tr>
267             
268             <tr>
269                 
270                 <td>整数行列</td>
271                 
272                 <td>
273                     
274                     <literal>i</literal>
275                     
276                 </td>
277                 
278                 <td>
279                     
280                     <literal>int8, int16, int32, uint8, uint16, uint32</literal>
281                     
282                 </td>
283                 
284                 <td/>
285                 
286             </tr>
287             
288             <tr>
289                 
290                 <td>文字列行列</td>
291                 
292                 <td>
293                     
294                     <literal>c</literal>
295                     
296                 </td>
297                 
298                 <td>
299                     
300                     <literal>文字列</literal>
301                     
302                 </td>
303                 
304                 <td/>
305                 
306             </tr>
307             
308             <tr>
309                 
310                 <td>ハンドル</td>
311                 
312                 <td>
313                     
314                     <literal>h</literal>
315                     
316                 </td>
317                 
318                 <td>
319                     
320                     <literal>ハンドル</literal>
321                     
322                 </td>
323                 
324                 <td/>
325                 
326             </tr>
327             
328             <tr>
329                 
330                 <td>コンパイルされた関数</td>
331                 
332                 <td>
333                     
334                     <literal>fptr</literal>
335                     
336                 </td>
337                 
338                 <td>
339                     
340                     <literal>fptr</literal>
341                     
342                 </td>
343                 
344                 <td/>
345                 
346             </tr>
347             
348             <tr>
349                 
350                 <td>スクリプト関数</td>
351                 
352                 <td>
353                     
354                     <literal>mc</literal>
355                     
356                 </td>
357                 
358                 <td>
359                     
360                     <literal>関数</literal>
361                     
362                 </td>
363                 
364                 <td/>
365                 
366             </tr>
367             
368             <tr>
369                 
370                 <td>ライブラリ</td>
371                 
372                 <td>
373                     
374                     <literal>l</literal>
375                     
376                 </td>
377                 
378                 <td>
379                     
380                     <literal>ライブラリ</literal>
381                     
382                 </td>
383                 
384                 <td/>
385                 
386             </tr>
387             
388             <tr>
389                 
390                 <td>リスト</td>
391                 
392                 <td>
393                     
394                     <literal>l</literal>
395                     
396                 </td>
397                 
398                 <td>
399                     
400                     <literal>リスト</literal>
401                     
402                 </td>
403                 
404                 <td/>
405                 
406             </tr>
407             
408             <tr>
409                 
410                 <td>tlist</td>
411                 
412                 <td>
413                     
414                     <literal>tlist型</literal>
415                     
416                 </td>
417                 
418                 <td>
419                     
420                     <literal>tlist型</literal>
421                     
422                 </td>
423                 
424                 <td>最初のtlistエントリの最初の文字列</td>
425                 
426             </tr>
427             
428             <tr>
429                 
430                 <td>mlist</td>
431                 
432                 <td>
433                     
434                     <literal>mlist型</literal>
435                     
436                 </td>
437                 
438                 <td>
439                     
440                     <literal>mlist型</literal>
441                     
442                 </td>
443                 
444                 <td>最初のmlistエントリの最初の文字列</td>
445                 
446             </tr>
447             
448             <tr>
449                 
450                 <td>ハイパー行列</td>
451                 
452                 <td>
453                     
454                     <literal>hm</literal>
455                     
456                 </td>
457                 
458                 <td>
459                     
460                     <literal>hypermat</literal>
461                     
462                 </td>
463                 
464                 <td/>
465                 
466             </tr>
467             
468             <tr>
469                 
470                 <td>ポインタ</td>
471                 
472                 <td>
473                     
474                     <literal>ptr</literal>
475                     
476                 </td>
477                 
478                 <td>
479                     
480                     <literal>ポインタ</literal>
481                     
482                 </td>
483                 
484                 <td/>
485                 
486             </tr>
487             
488             <tr>
489                 
490                 <td>セル</td>
491                 
492                 <td>
493                     
494                     <literal>ce</literal>
495                     
496                 </td>
497                 
498                 <td>
499                     
500                     <literal>ce</literal>
501                     
502                 </td>
503                 
504                 <td/>
505                 
506             </tr>
507             
508             <tr>
509                 
510                 <td>structure</td>
511                 
512                 <td>
513                     
514                     <literal>st</literal>
515                     
516                 </td>
517                 
518                 <td>
519                     
520                     <literal>st</literal>
521                     
522                 </td>
523                 
524                 <td/>
525                 
526             </tr>
527             
528             <tr>
529                 
530                 <td>有理数</td>
531                 
532                 <td>
533                     
534                     <literal>r</literal>
535                     
536                 </td>
537                 
538                 <td>
539                     
540                     <literal>有理数</literal>
541                     
542                 </td>
543                 
544                 <td/>
545                 
546             </tr>
547             
548             <tr>
549                 
550                 <td>線形状態空間</td>
551                 
552                 <td>
553                     
554                     <literal>lss</literal>
555                     
556                 </td>
557                 
558                 <td>
559                     
560                     <literal>状態空間</literal>
561                     
562                 </td>
563                 
564                 <td/>
565                 
566             </tr>
567             
568             <tr>
569                 
570                 <td>暗黙の多項式</td>
571                 
572                 <td>
573                     
574                     <literal>ip</literal>
575                     
576                 </td>
577                 
578                 <td>
579                     
580                     <literal>size implicit</literal>
581                     
582                 </td>
583                 
584                 <td>1:1:$</td>
585                 
586             </tr>
587             
588         </informaltable>
589         
590         <para>
591             
592             <literal>&lt;op_code&gt;</literal> は, 以下のテーブルに記述された
593             
594             各演算子に関連する文字です:
595             
596         </para>
597         
598         <informaltable border="1">
599             
600             <tr>
601                 
602                 <td>
603                     
604                     <literal>op</literal>
605                     
606                 </td>
607                 
608                 <td>char code</td>
609                 
610             </tr>
611             
612             <tr>
613                 
614                 <td>
615                     
616                     <literal>'</literal>
617                     
618                 </td>
619                 
620                 <td>t</td>
621                 
622             </tr>
623             
624             <tr>
625                 
626                 <td>
627                     
628                     <literal>+</literal>
629                     
630                 </td>
631                 
632                 <td>a</td>
633                 
634             </tr>
635             
636             <tr>
637                 
638                 <td>
639                     
640                     <literal>-</literal>
641                     
642                 </td>
643                 
644                 <td>s</td>
645                 
646             </tr>
647             
648             <tr>
649                 
650                 <td>
651                     
652                     <literal>*</literal>
653                     
654                 </td>
655                 
656                 <td>m</td>
657                 
658             </tr>
659             
660             <tr>
661                 
662                 <td>
663                     
664                     <literal>/</literal>
665                     
666                 </td>
667                 
668                 <td>r</td>
669                 
670             </tr>
671             
672             <tr>
673                 
674                 <td>
675                     
676                     <literal>\</literal>
677                     
678                 </td>
679                 
680                 <td>l</td>
681                 
682             </tr>
683             
684             <tr>
685                 
686                 <td>
687                     
688                     <literal>^</literal>
689                     
690                 </td>
691                 
692                 <td>p</td>
693                 
694             </tr>
695             
696             <tr>
697                 
698                 <td>
699                     
700                     <literal>.*</literal>
701                     
702                 </td>
703                 
704                 <td>x</td>
705                 
706             </tr>
707             
708             <tr>
709                 
710                 <td>
711                     
712                     <literal>./</literal>
713                     
714                 </td>
715                 
716                 <td>d</td>
717                 
718             </tr>
719             
720             <tr>
721                 
722                 <td>
723                     
724                     <literal>.\</literal>
725                     
726                 </td>
727                 
728                 <td>q</td>
729                 
730             </tr>
731             
732             <tr>
733                 
734                 <td>
735                     
736                     <literal>.*.</literal>
737                     
738                 </td>
739                 
740                 <td>k</td>
741                 
742             </tr>
743             
744             <tr>
745                 
746                 <td>
747                     
748                     <literal>./.</literal>
749                     
750                 </td>
751                 
752                 <td>y</td>
753                 
754             </tr>
755             
756             <tr>
757                 
758                 <td>
759                     
760                     <literal>.\.</literal>
761                     
762                 </td>
763                 
764                 <td>z</td>
765                 
766             </tr>
767             
768             <tr>
769                 
770                 <td>
771                     
772                     <literal>:</literal>
773                     
774                 </td>
775                 
776                 <td>b</td>
777                 
778             </tr>
779             
780             <tr>
781                 
782                 <td>
783                     
784                     <literal>*.</literal>
785                     
786                 </td>
787                 
788                 <td>u</td>
789                 
790             </tr>
791             
792             <tr>
793                 
794                 <td>
795                     
796                     <literal>/.</literal>
797                     
798                 </td>
799                 
800                 <td>v</td>
801                 
802             </tr>
803             
804             <tr>
805                 
806                 <td>
807                     
808                     <literal>\.</literal>
809                     
810                 </td>
811                 
812                 <td>w</td>
813                 
814             </tr>
815             
816             <tr>
817                 
818                 <td>
819                     
820                     <literal>[a,b]</literal>
821                     
822                 </td>
823                 
824                 <td>c</td>
825                 
826             </tr>
827             
828             <tr>
829                 
830                 <td>
831                     
832                     <literal>[a;b]</literal>
833                     
834                 </td>
835                 
836                 <td>f</td>
837                 
838             </tr>
839             
840             <tr>
841                 
842                 <td>
843                     
844                     <literal>() extraction</literal>
845                     
846                 </td>
847                 
848                 <td>e</td>
849                 
850             </tr>
851             
852             <tr>
853                 
854                 <td>
855                     
856                     <literal>() insertion</literal>
857                     
858                 </td>
859                 
860                 <td>i</td>
861                 
862             </tr>
863             
864             <tr>
865                 
866                 <td>
867                     
868                     <literal>==</literal>
869                     
870                 </td>
871                 
872                 <td>o</td>
873                 
874             </tr>
875             
876             <tr>
877                 
878                 <td>
879                     
880                     <literal>&lt;&gt;</literal>
881                     
882                 </td>
883                 
884                 <td>n</td>
885                 
886             </tr>
887             
888             <tr>
889                 
890                 <td>
891                     
892                     <literal>|</literal>
893                     
894                 </td>
895                 
896                 <td>g</td>
897                 
898             </tr>
899             
900             <tr>
901                 
902                 <td>
903                     
904                     <literal>&amp;</literal>
905                     
906                 </td>
907                 
908                 <td>h</td>
909                 
910             </tr>
911             
912             <tr>
913                 
914                 <td>
915                     
916                     <literal>.^</literal>
917                     
918                 </td>
919                 
920                 <td>j</td>
921                 
922             </tr>
923             
924             <tr>
925                 
926                 <td>
927                     
928                     <literal>.'</literal>
929                     
930                 </td>
931                 
932                 <td>0</td>
933                 
934             </tr>
935             
936             <tr>
937                 
938                 <td>
939                     
940                     <literal>&lt;</literal>
941                     
942                 </td>
943                 
944                 <td>1</td>
945                 
946             </tr>
947             
948             <tr>
949                 
950                 <td>
951                     
952                     <literal>&gt;</literal>
953                     
954                 </td>
955                 
956                 <td>2</td>
957                 
958             </tr>
959             
960             <tr>
961                 
962                 <td>
963                     
964                     <literal>&lt;=</literal>
965                     
966                 </td>
967                 
968                 <td>3</td>
969                 
970             </tr>
971             
972             <tr>
973                 
974                 <td>
975                     
976                     <literal>&gt;=</literal>
977                     
978                 </td>
979                 
980                 <td>4</td>
981                 
982             </tr>
983             
984             <tr>
985                 
986                 <td>
987                     
988                     <literal>~</literal>
989                     
990                 </td>
991                 
992                 <td>5</td>
993                 
994             </tr>
995             
996             <tr>
997                 
998                 <td>
999                     
1000                     <literal>iext</literal>
1001                     
1002                 </td>
1003                 
1004                 <td>6</td>
1005                 
1006             </tr>
1007             
1008         </informaltable>
1009         
1010         <para>
1011             
1012             展開構文<literal>b=a(i1,...,in)</literal>の オーバーロード関数は,
1013             
1014             以下のような呼び出し手順となります:
1015             
1016             <literal>b=%&lt;type_of_a&gt;_e_(i1,...,in,a)</literal>
1017             
1018         </para>
1019         
1020         <para>
1021             
1022             そして,構文 <literal>[x1,..,xm]=a(i1,...,in)</literal> は
1023             
1024             以下のような呼び出し手順となります:
1025             
1026             <literal>[x1,..,xm]=%&lt;type_of_a&gt;_e_(i1,...,in,a)</literal>
1027             
1028         </para>
1029         
1030         <para>
1031             
1032             挿入構文に関するオーバーロード関数 <literal>a(i1,...,in)=b</literal>
1033             
1034             は以下のような呼び出し手順となります:
1035             
1036             <literal>a=%&lt;type_of_b&gt;_i_&lt;type_of_a&gt;(i1,...,in,b,a)</literal>.
1037             
1038         </para>
1039         
1040         <para>
1041             
1042             文字コード<literal>6</literal> を
1043             
1044             <code>x.b(2) = 33</code>のような複雑な挿入アルゴリズム で使用することができます.
1045             
1046             ただし,<literal>b</literal>フィールドは構造体<literal>x</literal>で 定義されません.
1047             
1048             挿入は自動的に<literal>temp=x.b;</literal> <code>temp(2) = 33</code>;
1049             
1050             <code>x.b = temp</code>に分解されます. 文字コード<literal>6</literal>
1051             
1052             がこのアルゴリズムの最初の手順で 使用されます.オーバーロード関数<literal>6</literal> は,
1053             
1054             <literal>e</literal>のものに非常によく似ています.
1055             
1056         </para>
1057         
1058         <variablelist>
1059             
1060             <varlistentry>
1061                 
1062                 <term>関数 :</term>
1063                 
1064                 <listitem>
1065                     
1066                     <para>
1067                         
1068                         いくつかの基本プリミティブ関数新規データ型に関してオーバーロードができます. 
1069                         
1070                         特定のデータ型に関してこのような関数が未定義の場合,
1071                         
1072                         関数<literal>%&lt;type_of_an_argument&gt;_&lt;function_name&gt;</literal>
1073                         
1074                         がコールされます. ユーザはこのコールされた関数に入力データ型に関する
1075                         
1076                         定義を追加することができます.
1077                         
1078                     </para>
1079                     
1080                 </listitem>
1081                 
1082             </varlistentry>
1083             
1084         </variablelist>
1085         
1086     </refsection>
1087     
1088     <refsection>
1089         
1090         <title>例</title>
1091         
1092     </refsection>
1093     
1094     <refsection>
1095         
1096         <programlisting role="example">//表示
1097             
1098             var = tlist('tab', ['a', 'b'], ['x'; 'y'], rand(2, 2)) // varの型は 'tab'です
1099             
1100             
1101             
1102             typeof(var)
1103             
1104             
1105             
1106             function [] = %tab_p(l)
1107             
1108             disp([[' '; l(3)] [l(2); string(l(4))]])
1109             
1110             endfunction
1111             
1112             
1113             
1114             var // オーバーローディング後
1115             
1116         </programlisting>
1117         
1118     </refsection>
1119     
1120     <refsection>
1121         
1122         <programlisting role="example">//演算子
1123             
1124             's' + 1 // 数値は文字列に加算できません
1125             
1126             
1127             
1128             function x = %c_a_s(a, b)
1129             
1130             x = a + string(b);
1131             
1132             endfunction
1133             
1134             
1135             
1136             's' + 1 // オーバーローディング後
1137             
1138         </programlisting>
1139         
1140     </refsection>
1141     
1142     <refsection>
1143         
1144         <programlisting role="example">//関数
1145             
1146             sin('2 * x') // sin関数は文字列では動作しません
1147             
1148             
1149             
1150             function x = %c_sin(a)
1151             
1152             x = 'sin(' + a + ')'
1153             
1154             endfunction
1155             
1156             
1157             
1158             sin('2 * x') // オーバーローディング後
1159             
1160         </programlisting>
1161         
1162     </refsection>
1163     
1164     <refsection role="see also">
1165         
1166         <title>参照</title>
1167         
1168         <simplelist type="inline">
1169             
1170             <member>
1171                 
1172                 <link linkend="tlist">tlist</link>
1173                 
1174             </member>
1175             
1176             <member>
1177                 
1178                 <link linkend="disp">disp</link>
1179                 
1180             </member>
1181             
1182             <member>
1183                 
1184                 <link linkend="symbols">symbols</link>
1185                 
1186             </member>
1187             
1188             <member>
1189                 
1190                 <link linkend="typeof">typeof</link>
1191                 
1192             </member>
1193             
1194             <member>
1195                 
1196                 <link linkend="type">type</link>
1197                 
1198             </member>
1199             
1200             <member>
1201                 
1202                 <link linkend="typename">typename</link>
1203                 
1204             </member>
1205             
1206         </simplelist>
1207         
1208     </refsection>
1209     
1210 </refentry>
1211