matlab.unittest.constraints.IsSparse クラス
パッケージ: matlab.unittest.constraints
スーパークラス: matlab.unittest.constraints.BooleanConstraint
スパース配列を指定する制約
構築
IsSparse
は、スパース配列を指定する制約を作成します。この制約は、実際の値がスパースである場合にのみ満たされます。
コピーのセマンティクス
値。値クラスがコピー操作に与える影響については、オブジェクトのコピーを参照してください。
例
実際の値の配列がスパースであることをテスト
対話型テスト用にテスト ケースを作成します。
import matlab.unittest.TestCase import matlab.unittest.constraints.IsSparse testCase = TestCase.forInteractiveUse;
単位行列を作成し、それがスパースであるかどうかをテストします。
F = eye(7); testCase.verifyThat(F, IsSparse)
Interactive verification failed. --------------------- Framework Diagnostic: --------------------- IsSparse failed. --> The value must be sparse. Actual Value: 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1
行列 F
は非スパース行列です。
F
をスパース行列に変換して、スパース性を再テストします。
S = sparse(F); testCase.verifyThat(S, IsSparse)
Interactive verification passed.
参考
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)